Reporting Documents
시간 제한1초메모리 제한2048 MB
이진 배열에서 한 원소씩 갱신하는 연산과, 각 질의 (x, k)마다 x, x+k, x+2k, ... 처럼 등차수열을 이루는 위치 중 값이 0인 개수를 세는 문제이다.
문제
Each citizen in ICPC Kingdom must have their kingdom-issued documents, numbered from to , 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 where represents the existence of document . If document $$i is on his hand, then . Otherwise, if document is missing.
For each of the next days, exactly one of the following scenarios will happen.
- . Adrian found his missing document , so is updated to (it is guaranteed that right before this scenario).
- . Adrian lost his document , so is updated to (it is guaranteed that right before this scenario).
- . A guard asks Adrian for document , where , for all that satisfies and . For each document he couldn’t provide when the guard asked for it, Adrian will be fined for coin.
For each scenarios involving a guard (i.e. scenario ), Adrian asks you to count how many coins he needs to pay for the fine.
입력
Input begins with an integer () representing the number of documents. The next line contains a string of length , where the th character of is (), the initial existence status of document .
The next line contains an integer () representing the number of days. Each of the next lines contains a scenario. Each scenario begins with an integer (). If or , then it is followed by an integer () representing scenario or , respectively. It is guaranteed that integer in scenarios and satisfy the scenario description. If , then it is followed by two integers () representing scenario . There will be at least one scenario of type .
출력
For each scenario , output an integer in a single line representing how many coins Adrian needs to pay for the fine for that day.