AtCoder Regular Contest 203 (Div. 2)
翻译中…
Problem Statement
翻译中…
There is an integer sequence $A=(A_1,A_2,\dots,A_N)$ of length $N$ consisting of $0$ and $1$. You are given $Q$ queries. The $q$-th query is as follows:
翻译中…
- An integer
$i_q$between$1$and$N$is given. Change$A_{i_q}$to$1$if it is$0$, and to$0$if it is$1$.
翻译中…
After processing each query, find the answer to the following problem:
翻译中…
Consider sequences
$B=(B_1,B_2,\dots,B_{|B|})$consisting of$0$and$1$that satisfy the following condition:
- By performing the following operation any number of times on
$B$, it can be made to match sequence$A$:- Choose an integer
$i$between$1$and$|B|-1$, inclusive.
- Insert
$B_i\oplus B_{i+1}$between$B_i$and$B_{i+1}$.It can be proved that there always exists a
B
that satisfies the condition. Find the minimum possible value of
|B|
.
翻译中…
Constraints
翻译中…
$3 \leq N \leq 2 \times 10^5$$0 \leq A_i \leq 1$$1 \leq Q \leq 5 \times 10^5$$1 \leq i_q \leq N$- All input values are integers.
翻译中…
Input
翻译中…
The input is given from Standard Input in the following format:
翻译中…
N
A_1 A_2 \dots A_N
Q
i_1
i_2
\vdots
i_Q
翻译中…
Output
翻译中…
Output the answers in a total of $Q$ lines. The $q$-th line should contain the answer to the problem after processing the $q$-th query.
翻译中…
样例
Input #1
3
0 0 0
2
1
2
Output #1
3
2
When $A=(1,0,0)$, $|B|$ is minimized by $B=(1,0,0)$. When $A=(1,1,0)$, $|B|$ is minimized by $B=(1,0)$.
Input #2
8
0 1 0 0 1 1 1 0
3
1
4
1
Output #2
5
2
3
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。