Solved by 240 users: ...
UserDateAttemptTimeCMSC
Abzal_ktl`27 dec 2007`Kylix100.01238
LOD`24 may 2017`C++100.01301
fetetriste`01 may 2008`C++700.01407
Fenriz`09 aug 2004`FPC3?.??410
checkil`12 dec 2008`C++100.01431
Nikol`12 dec 2008`C++200.01431
Oleg42`25 dec 2010`C++100.01441
oleg.dudrov`15 jan 2011`C++100.01441
Vladislav_Simonenko`05 oct 2006`C++200.01445
registration`25 dec 2007`C++300.01453
 C++ 136 FPC 60 Kylix 16 C 14 Java 13 Ruby 1
` >  >  >  >  >  >  >  >  >  > `

## Bridges

Time limit = 5 seconds

The 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.

 Input#1```3 .B. R.R .B. ``` Output#1```1 ```
 Input#2```7 .B.BBB. RBR.RRR .B.B.B. RRRRR.R .B.B.B. R.R.R.R .B.B.B. ``` Output#2```2 ```
 Input#3```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. ``` Output#3```0 ```

Author:
Voroztsov Artem, MIPT Contest, February 2003
16 Fabruary 2003

<PREV | Problem set | Search related messages | NEXT>

 © acm.mipt DevGroupThe page was generated in 210ms