DWITE Online Computer Programming Contest, December 2007, Problem 5
In an experiment gone horribly wrong, a number of portals have gotten installed in a house. The portals come in a directional variety, that is – one entrance and one exit node. Calculating the area of rooms has suddenly become a lot trickier.
The input will contain two lines with one integer value each,
#
- wall.
- open space- {
a
-j
,A
-J
} - marking entrance and exit nodes of portals - {
1
-5
} - integers 1 to 5, marking rooms of interest
Lowercase letters mark entrance nodes, while corresponding capital letters mark exit nodes. That is, one can enter at point j
and exit at point J
. There will be no more than
The output will contain 5 lines. Each line will have an integer representing the area of a room of interest. First line should contain the area of room 1, second line of room 2, etc.
The area of the room is defined as
Sample Input
10
11
1.#.2...#A.
..#.a...#..
###########
3.b.#B.#...
....#c.#.C.
###########
4........#.
.d...D...#.
##########.
..........5
Sample Output
4
14
18
18
14
Problem Resource: DWITE
Comments