|
|||
Turn the Lights OffSince we all rely on mother earth, it's our duty to save her. Therefore, you're now asked to save energy by switching lights off. A friend of yours has the following problem in his job. There's a grid of size 10×10, where each square has a light bulb and a light switch attached to it. Unfortunately, these lights don't work as they are supposed to. Whenever a switch is pressed, not only its own bulb is switched, but also the ones left, right, above, and under it. Of course, if a bulb is on the edge of the grid, there are fewer bulbs switched.
When a light switches, it means it's now on if it was off before, and it's now off if
it was on before. Look at the following examples, which show only a small part of the
whole grid. They show what happens if the middle switch is pressed.
“ ### #O# ### -> OOO ### #O# ### #O# OOO -> ### ### #O# Your friend loves to save energy and asks you to write a program that finds out if it is possible to turn all the lights off, and if possible then how many times he has to press switches in order to turn all the lights off. Input Specification
There are several test cases in the input. Each test case is preceded by a single word
that gives a name for the test case. The length of the name is between 1 and 100
characters. After that name there follow 10 lines, each of which contains a
10-character string consisting of “ Output SpecificationFor every test case, print one line that consists of the test case name, a single space character, and the minimum number of times your friend has to press a switch. If it is not possible to switch off all the lights, or it requires more than 100 presses, then the case name should be followed by a space and the number –1. Sample Input
Output for Sample Input
|
|||
University of Debrecen; Faculty of Informatics; v. 09/30/2024 |