Due to the latest earthquake occurrences, the government of "Intelligent Country" is trying to devise a mechanism which can accurately identify the danger zones based on the origin / epicenter of the earthquake. The mechanism requires that the local map, the co-ordinates of the epicenter and the intensity (measured in Richter scale) are provided as inputs to the program. The output of the program would be the map marked with affected areas.
The local map is represented as a grid with square dimensions containing 0's and 1's only. 0's denote the areas which are water whereas 1 denotes the land areas. Based on the epicenter co-ordinates, all the neighboring inhabited areas that would be affected needs to be marked as '2'. This process will continue until all the neighboring land areas are processed. Based on the intensity provided, the areas which would be most affected should be marked as "high risk zones" denoted by '3'. The below table should be used for reference.
All reachable land areas would be marked as affected areas.
>3.0 and <=5.0
The immediate neighbors to the epicenter are the high risk zones.
>5.0 and <=8.0
The first three immediate neighbors would be marked as high risk zones.
All reachable land areas would be marked as high risk zones.
Table 1: Intensity-Impact Table
File name, where file contains the information in format described below:
First line contains an integer N which denotes the size of the grid
Next N lines each contain N elements delimited by space. These elements are only 0's and 1's
Next line contains the coordinate of the epicenter. The following applies to the Epicenter
It always has to be a land area i.e. it has to be denoted by 1
Row and column indexes of the grid start with 1, not 0
Coordinates are delimited by space and are of format
Last line contains a float value, which denotes intensity of the earthquake in Richter scale
The output or the resulting map (in the form of the square matrix) should be displayed
Note how epicenter (3, 3) is highlighted in 3rd row and 3rd column.
The intensity of quake is 3.5. Hence according to Intensity-Impact Table we have to consider immediate neighbours. The immediate land neighbours are [(2,4) (4,3) and (4,4)]. Per rules, they are set to high risk zone, denoted by 3. The epicenter is also marked as high risk zone.
The intensity of quake is 6.95. Hence according to Intensity-Impact Table we have to consider three immediate neighbours. Three immediate neighbours is a perimeter of 3 units from the epicenter. In this case the epicenter is (4,1). Hence the perimeter is from coordinates (1, 1) to (7, 4).Now applying, the rules we get the depicted output. Note that the epicenter is also marked as high risk zone.
1 0 1 1
0 0 0 1
1 0 0 1
0 0 1 1
1 0 3 3
0 0 0 3
1 0 0 3
0 0 3 3
The intensity of quake is 8.95. Hence according to Intensity-Impact Table we have to consider all reachable land neighbours through which the quake can propagate.
1 0 1 1
0 0 0 1
1 0 0 1
0 0 1 1
1 0 2 2
0 0 0 2
1 0 0 2
0 0 2 2
The intensity of quake is 1.95. Hence according to Intensity-Impact Table we have to consider all reachable land neighbours and mark them as affected areas, denoted by 2. The epicenter is also marked as affected area.
Please do not use package and namespace in your code. For object oriented languages your code should be written in one class.
Participants submitting solutions in C language should not use functions from / as these files do not exist in gcc
For C and C++, return type of main() function should be int.