DWITE Online Computer Programming Contest

Oil Spill Area

May 2010
Problem 3

We want to measure globs of oil spills by calculating their area from satellite images. There could be multiple disconnected globs in a single image, so the area of interest is marked.

The input file DATA3.txt will contain 5 sets of input, each a 10×10 grid. Each set is followed by a line of 10 = signs, to visually break up test cases.

The output file OUT3.txt will contain 5 lines of output, with each being an integer 1 ≤ N ≤ 100 representing the area of the corresponding oil glob of interest.

Note: Only up/down and left/right adjacent cells are connected. Diagonals are not.

Sample Input (first two shown):
..........
.##.......
...#......
....###...
....#A#...
....###...
..........
..........
..........
..........
==========
..........
...######.
...#....#.
...#.##.#.
...##A#.#.
........#.
.......##.
..........
##........
##........
==========
Sample Output (first two shown):
9
20