#P2040. 打开所有的灯
打开所有的灯
Description
These lights behave in a peculiar (annoying) way: pressing a light will flip the on/off state of that light and its four neighboring lights. Your task is to tell pmshz how to turn all the lights on.
For example
0 1 1
1 0 0
1 0 1
Pressing the center light becomes
0 0 1
0 1 1
1 1 1
Pressing the top-left light becomes
1 1 1
1 1 1
1 1 1
Goal achieved.
The minimum number of steps is .
Input Format
numbers given in a layout, with exactly one space between adjacent numbers, representing the initial on/off state of the lights ( means off, means on).
Output Format
A single integer, the minimum number of presses required to turn on all the lights.
0 1 1
1 0 0
1 0 1
2
Hint
How easy this problem is depends on how you think about it.
Translated by ChatGPT 5
京公网安备 11011102002149号