| TheForces Round #37 (Brute-Forces1) |
|---|
| Finished |
An integer array $$$b$$$ containing $$$m$$$ elements is called perfect-prefix array, if it satisfies the following condition :
You can do the following operation on $$$b$$$ any number of times (possibly zero) :
Let $$$f(b)$$$ be the minimum number of operations required to turn $$$b$$$ into perfect-prefix array. If it is not possible to turn $$$b$$$ into perfect-prefix array then $$$f(b) = -1$$$.
You are given an integer array $$$a$$$ containing $$$n$$$ elements where each element is either $$$1$$$ or $$$-1$$$.
Now your task is to answer $$$q$$$ queries of following type :
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). The description of the test cases follows.
The first line of each test case contains two integers $$$n,q$$$ ($$$1 \le n,q \le 5 \cdot 10^5$$$) — the size of the array and the number of queries.
The second line of each test case contains $$$n$$$ space separated integers $$$a_{i}$$$ ($$$-1 \le a_{i} \le 1$$$ , $$$a_i ≠ 0$$$).
The next $$$q$$$ lines contain one of the two forms:
It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$5 \cdot 10^5$$$.
It is guaranteed that the sum of $$$q$$$ over all test cases doesn't exceed $$$5 \cdot 10^5$$$.
For each test case, print the required answer for the $$$1$$$-st type query.
25 51 1 -1 1 -11 1 41 2 42 31 1 41 4 511 61 1 1 1 -1 -1 -1 1 1 -1 -11 7 91 1 112 52 61 1 71 7 10
0 1 0 -1 1 0 0 -1
| Name |
|---|


