How Many People Can Survive

Time Limit: 1000ms
Memory Limit: 32768KB
This problem will be judged on HDU. Original ID: 2267
64-bit integer IO format: %I64d      Java class name: Main

Description

Two opposing armies are lost in a big forest. The forest is dangerous ,because it is filled with poisonous gas . People can only survive by staying at the place that is surrounded by trees.As the two armies are opposing, if one army are able to move to the other one , they wil fight with each other. Only the army that with the more people will survive, if the number is equal, no one will survive. Now you are asked to find out how many people will survive.

Input

There are several test cases.
Each case begins with an integer n and m (3<=n,m<=300) stands for the size of forest.
Then follows n lines , each line contains m characters .
‘.’ Stands for empty place
‘#’Stands for tree and can’t been walked through
‘o’Stands for the first army
‘v’stands for the second army

Output

The output contains one line for each data set : two integers, p and q, stands for the number of the first army that can survive and the number of the second army that can survive.

Sample Input

3 3
..#
ovo
…
10 10
...vvvoo..
##########
#....oo.o#
#..v.v...#
#........#
#..####..#
#..#o.#..#
#..#.v#..#
#..####..#
##########

Sample Output

0 0
3 0

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .