| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 2048 MB | 3 | 2 | 2 | 66.667% |
Each citizen in ICPC Kingdom must have their $N$ kingdom-issued documents, numbered from $1$ to $N$, on their hands at any time. The guards often ask random citizens for their documents during their patrol.
As a citizen of ICPC Kingdom, Adrian also has these documents on his hands as well; however, some of them might be missing due to his negligence. The existence status of all of his documents are represented by a string $B$ where $B_i$ represents the existence of document $i$. If document $$i is on his hand, then $B_i = 1$. Otherwise, $B_i = 0$ if document $i$ is missing.
For each of the next $Q$ days, exactly one of the following scenarios will happen.
For each scenarios involving a guard (i.e. scenario $3$), Adrian asks you to count how many coins he needs to pay for the fine.
Input begins with an integer $N$ ($1 ≤ N ≤ 200\, 000$) representing the number of documents. The next line contains a string $B$ of length $N$, where the $i$th character of $B$ is $B_i$ ($B_i \in \{ 0, 1\}$), the initial existence status of document $i$.
The next line contains an integer $Q$ ($1 ≤ Q ≤ 200\, 000$) representing the number of days. Each of the next $Q$ lines contains a scenario. Each scenario begins with an integer $t$ ($t \in \{1, 2, 3\}$). If $t = 1$ or $t = 2$, then it is followed by an integer $x$ ($1 ≤ x ≤ N$) representing scenario $1$ or $2$, respectively. It is guaranteed that integer $x$ in scenarios $1$ and $2$ satisfy the scenario description. If $t = 3$, then it is followed by two integers $x$ $k$ ($1 ≤ x ≤ k ≤ N$) representing scenario $3$. There will be at least one scenario of type $3$.
For each scenario $3$, output an integer in a single line representing how many coins Adrian needs to pay for the fine for that day.
10 1010001001 5 3 1 2 2 1 1 5 1 9 3 1 1
2 5
At first, Adrian only has documents $1$, $3$, $7$, and $10$ on his hand.
On day $1$, a guard asks Adrian for documents $1 + 2 \cdot i$, i.e. documents $1$, $3$, $5$, $7$, and $9$. Adrian doesn’t have documents $5$ and $9$ on his hand, thus, he will be fined for $2$ coins.
On day $2$, $3$, and $4$, he lost document $1$, found document $5$, and found document $9$, respectively.
On day $5$, a guard asks Adrian for documents $1 + 1 \cdot i$, i.e. all documents from $1$ to $10$. Adrian doesn’t have documents $1$, $2$, $4$, $6$, and $8$ on his hand, thus, he will be fined for $5$ coins.
25 0010000010100110100000101 10 3 2 4 1 5 1 21 2 11 2 5 3 1 5 1 5 3 5 5 3 3 8 3 1 25
5 4 2 2 1
ICPC > Regionals > Asia Pacific > Indonesia > Indonesia National Contest > INC 2022 I번