#P2622. 关灯问题 II
关灯问题 II
Description
There are lamps and buttons. Each button can control all lamps simultaneously — pressing the -th button affects every lamp. For lamp , pressing button has one of the following three effects:
- If , then if this lamp is on, turn it off; otherwise do nothing.
- If , then if this lamp is off, turn it on; otherwise do nothing.
- If , do nothing regardless of the lamp’s state.
All lamps are initially on. Given the effects of every button on every lamp, find the minimum number of button presses needed to turn all lamps off.
Input Format
The first line contains the integer .
The second line contains the integer .
The next lines each contain integers. On line , the -th integer is , representing the effect of button on lamp .
Output Format
Output a single integer — the minimum number of button presses. If it is impossible to turn all lamps off, output .
3
2
1 0 1
-1 1 0
2
Hint
Constraints
- For of the testdata, printing “no solution” can score points.
- For of the testdata, .
- For of the testdata, .
The above test points may overlap.
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号