AbhayChandna's blog

By AbhayChandna, history, 4 years ago, In English

https://mirror.codeforces.com/contest/1353/problem/E

On input 
6
9 2
010001010
9 3
111100000
7 4
1111111
10 3
1001110101
1 1
1
1 1
0

Output is 
1
2
5
4
0
0

In the second testcase, how is the output 2?

if we swithc all off all lamps, 4 moves if we switch on lamps on index 0 3 6 , moves 3 (switch off {1,2} switch on{6})

if we switch on lamps on index 1 4 7 , moves 4 (switch off {0,2,3} switch on{7})

if we switch on lamps on index 2 5 8 , moves 4 (switch off {0,1,3} switch on{8})

So , how is the minimum required moves 2?

Full text and comments »

  • Vote: I like it
  • -7
  • Vote: I do not like it