|Online MIPT programming contest||РУССКИЙ|
Time limit = 5 secondsThe Game "Bridges" is one of the strategic games in which the human mind bits the computer. Human mind is familiar with side-tracks, reserve ways, ruses and tricks. Human mind is a wild card, what can't be said about computer it does what it is programmed to do and nothing more.
We have square game field N × N, where N is odd.
Each cell has color, white, red or blue, and coordinates (x, y), x = 1, 2, ... N, y = 1, 2,..., N.
At the beginning cells with odd x and y, and cells with even x and y are white. Others are red or blue. See figure.
"Red player" begins and colors one of the white cells to red. Then "Blue player" moves colors one of white cells to blue. They make moves in turn. "Red player" should build red bridge from left to rigth side of the square. "Blue player" blue bridge from top to bottom side.
Try yourself here.
You are given description of game field after some moves made.
Write program which can determine "one move to bridges" and "two moves to bridge" positions.
Position is "one move to bridge" if the player whose turn can make move and build bridge.
Position is "two moves to bridge" if after any move of the player whose turn the second player will have possibility to move and build bridge.
Whose turn is can be determined by the number of blue and red cells.
Input. The first line has number N. Next N lines have N characters each. These characters are 'R', 'B' or '.'.
Output. Output 1 if "one move to bridge". Output 2 if "two moves to bridge". Output 0 if these are not cases.
3 .B. R.R .B.
7 .B.BBB. RBR.RRR .B.B.B. RRRRR.R .B.B.B. R.R.R.R .B.B.B.
7 .B.B.B. R.R.R.R .B.B.B. R.R.R.R .B.B.B. R.R.R.R .B.B.B.
Voroztsov Artem, MIPT Contest, February 2003
16 Fabruary 2003
© acm.mipt DevGroup
The page was generated in 190ms