Don't Fight The Music
시간 제한3초메모리 제한1024 MB
한 구간에 같은 색 개수 기반 토글 연산을 T번 적용했을 때 위로 보이는 값의 합을 구하고, 중간에 점 갱신과 뒤집기가 들어온다.
문제
There are cards in a row. Each card has a red front side and a blue back side. An integer is written on the red side of the -th card, and an integer is written on the blue side. Initially, every card is facing either red side up or blue side up.
An operation on a range is defined as follows:
- For each from to , let be the number of indices with such that card shows the same color as card at the beginning of the current operation.
- After the operation, card shows its red side if is even, and its blue side if is odd.
- All cards in are updated simultaneously.
You need to process the following queries:
1 i— Flip the -th card.2 i k— Change the value on the red side of the -th card to .3 i k— Change the value on the blue side of the -th card to .4 l r T— Calculate the sum of the numbers on the face-up sides in the range , when the operation has been applied to this range times. The state of the cards does not change as a result of this query.
입력
The first line contains a single integer , the number of cards.
The second line contains a string of length , consisting of characters R and B. The -th character of denotes the initial side of the -th card (R for red side up, B for blue side up).
The third line contains integers — the values on the red sides of the cards.
The fourth line contains integers — the values on the blue sides of the cards.
The fifth line contains a single integer , the number of queries.
Each of the next lines describes a query of one of the four types as described above.
출력
For each query of type , output a single integer, the calculated sum for the specified range.
제한
- For a query of type :
- For a query of type or : ,
- For a query of type : ,
- It is guaranteed that there is at least one query of type 4.