15-19 февраля. Старшая лига - Дерево отрезков - множественная модификация
The sequence of n opening and closing parentheses are given. You have k queries for changing a single bracket to opposite (the opening bracket changes to closing and otherwise). After each query you must answer does the current sequence of brackets is correct.
The bracket sequence is called correct if the number of opening brackets equals to the number of closing, and in any prefix of the sequence the number of opening brackets is no less then number of closing brackets.
The first line contains n (1 ≤ n ≤ 100 000) parentheses. The second line contains the number of queries k (1 ≤ k ≤ 100 000). Each of the next k lines contains one number p (0 ≤ p < n) - the bracket number that must be changed to opposite.
Print k lines. In each line print either '+' or '–' depending on the correctness of the current bracket sequence after executing the current query.
() 5 0 0 1 1 0
- + - + -