A house has windows arranged in a row, numbered from to .
There are alarms. You are given an array . Alarm monitors exactly the consecutive windows .
An alarm is on if at least one window it monitors is open, and off otherwise. You can see the state of every alarm separately.
You may permanently lock some windows closed. Afterward, at most one unlocked window will be open at any moment; it is also possible that all windows are closed. Locking a window does not change which windows the alarms monitor.
Find the minimum number of windows you must permanently lock so that the alarm states always determine exactly which window is open, or determine that all windows are closed.
Lock windows and . Opening one of windows triggers, respectively, alarm sets , , , , and . These are all different and nonempty. At least one window from each pair and must be locked, since the two windows in either pair trigger exactly the same alarms.
Lock windows . Opening window , , or triggers only alarm , , or , respectively. In each pair , , and , at least one window must be locked.
Windows are not monitored by any alarm, so opening one would look the same as leaving every window closed. They must all be locked. At least one window from each pair and must also be locked. Keeping only windows and unlocked achieves the minimum of locked windows.
Opening windows triggers alarm sets , , , , and , respectively. These are all different and nonempty, so no window needs to be locked.
All three alarms monitor all four windows. Opening any window turns on every alarm, so at most one window may remain unlocked. Locking any three windows is sufficient.