Baltic Olympiad in Informatics: 2011 Day 1, Problem 3
Casper is designing an electronic circuit on an
A power source is connected to the top left corner of the plate. A lamp is connected to the bottom
right corner of the plate. The lamp is on only if there is a path of wires connecting power source to
lamp. In order to switch the lamp on, any number of tiles can be turned by

In the picture above the lamp is off. If any one of the tiles in the second column from the right is
turned by
Write a program to find out the minimal number of tiles that have to be turned by
Constraints
Subtask 1 [30%]
Subtask 2 [70%]
No additional constraints.
Input Specification
The first line of input contains two integer integers \
or /
– which indicate the direction of the wire
connecting the opposite vertices of the corresponding tile.
Output Specification
There must be exactly one line of output. If it is possible to switch the lamp on, this line must contain
only one integer: the minimal number of tiles that have to be turned to switch on the lamp. If
it is not possible, output the string: NO SOLUTION
.
Sample Input
3 5
\\/\\
\\///
/\\\\
Sample Output
1
Sample Explanation
This sample corresponds to the picture in the statement.
Comments