Subject to the effect:
There \ (n-\) lamp in a row, and \ (K \) switches, the \ (I \) switches can set \ (A_i \) in the lamp changes state (open \ (\ to \) oFF, oFF \ (\ to \) apart), and each lamp is controlled by a maximum of two switches .
All lights are given an initial state, for each satisfy \ (1 \ leqslant i \ leqslant n \) a \ (I \) , before calculating so that \ (I \) lamps are open, at least the number of switches.
Observed that each switch only two states: with and without. Set \ (P_i \) represents the use of \ (I \) switches.
If a light switch without any control, the skip.
If a lamp controlled by a switch, which is set \ (A \)
- If \ (S_I. 1 = \) , then \ (p_a \ leftrightarrow0, \ lnot p_a \ leftrightarrow1 \)
- If \ (S_I 0 = \) , then \ (p_a \ leftrightarrow1, \ lnot p_a \ leftrightarrow0 \)
If a lamp controlled by two switches, which is set \ (a, b \)
- 如果\(s_i=1\),则\(p_a\leftrightarrow p_b,\lnot p_a\leftrightarrow \lnot p_b\)
- 如果\(s_i=0\),则\(p_a\leftrightarrow\lnot p_b,\lnot p_a\leftrightarrow p_b\)
According to the above method \ (0,1, p_i, \ lnot p_i \) connected edge, and weights are assigned to the four \ (\ infty, 0,1,0 \) , selected according to the following method found the minimum weight is the answer and point sets.
\ (p_i \) and \ (\ lnot p_i \) in need and choose at least one. \ (0 \) and \ (1 \) is the same between.
Between points with the selected points must be connected to the selected edge. (I.e., each communication must select a full block)
Then is maintained in communication with disjoint-set the block ......