#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 (2,2)(2,2) becomes

0  0  1
0  1  1
1  1  1

Pressing the top-left light (1,1)(1,1) becomes

1  1  1
1  1  1
1  1  1

Goal achieved.

The minimum number of steps is 22.

Input Format

99 numbers given in a 3×33\times3 layout, with exactly one space between adjacent numbers, representing the initial on/off state of the lights (00 means off, 11 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