DRGHTS WA Help!

With reference to the question

Here’s my solution (which is WA):
http://www.codechef.com/viewsolution/5652577

The answer to the second part is confusing me. Do we need to even count those windows, which are lying between windows that are open? (This I added after I realized it from test cases in comments). Plus there’s a little issue that I am having at the moment.

For a test case like

15 14

0 1 0 0 0 1 1 1 0 0 1 0 1 0 0

1 2

2 3

3 4

3 5

3 7

5 6

7 8

7 9

9 10

9 11

11 12

11 13

11 14

14 15

Since 3 lies between two open windows 2 and 7, it acts as an open window(or a false-window). And so, 5 which is a child of 2, also acts as an open window because 3 acts as an open window. However, I am not able to incorporate this consideration into my code.

A little help in this regard would be appreciated. :slight_smile: