Logo
(追記) (追記ここまで)

34651번 - Don't Fight The Music 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 1024 MB28131244.444%

문제

There are $N$ cards in a row. Each card has a red front side and a blue back side. An integer $R_i$ is written on the red side of the $i$-th card, and an integer $B_i$ is written on the blue side. Initially, every card is facing either red side up or blue side up.

An operation on a range $[l, r]$ is defined as follows:

  • For each $i$ from $l$ to $r,ドル let $c_i$ be the number of indices $j$ with $l \le j < i$ such that card $j$ shows the same color as card $i$ at the beginning of the current operation.
  • After the operation, card $i$ shows its red side if $c_i$ is even, and its blue side if $c_i$ is odd.
  • All cards in $[l, r]$ are updated simultaneously.

You need to process the following $Q$ queries:

  • 1 i — Flip the $i$-th card.
  • 2 i k — Change the value on the red side of the $i$-th card to $k$.
  • 3 i k — Change the value on the blue side of the $i$-th card to $k$.
  • 4 l r T — Calculate the sum of the numbers on the face-up sides in the range $[l, r],ドル when the operation has been applied to this range $T$ times. The state of the cards does not change as a result of this query.

입력

The first line contains a single integer $N,ドル the number of cards.

The second line contains a string $s$ of length $N,ドル consisting of characters R and B. The $i$-th character of $s$ denotes the initial side of the $i$-th card (R for red side up, B for blue side up).

The third line contains $N$ integers $R_1, R_2, \cdots, R_N$ — the values on the red sides of the cards.

The fourth line contains $N$ integers $B_1, B_2, \cdots, B_N$ — the values on the blue sides of the cards.

The fifth line contains a single integer $Q,ドル the number of queries.

Each of the next $Q$ lines describes a query of one of the four types as described above.

출력

For each query of type 4ドル,ドル output a single integer, the calculated sum for the specified range.

제한

  • 1ドル \le N, Q \le 2\cdot 10^5$
  • 1ドル \le R_i, B_i \le 10^9$
  • For a query of type 1ドル$: 1ドル \le i \le N$
  • For a query of type 2ドル$ or 3ドル$: 1ドル \le i \le N,ドル 1ドル \le k \le 10^9$
  • For a query of type 4ドル$: 1ドル \le l \le r \le N,ドル 1ドル \le T \le 10^9$
  • It is guaranteed that there is at least one query of type 4.

예제 입력 1

5
RRRRR
1 2 3 2 1
5 4 3 4 5
4
4 1 5 1
4 1 5 2
1 2
4 1 4 1

예제 출력 1

13
11
8

예제 입력 2

8
RBRBRBRB
451 79 882 122 1289 242 2459 262
697 1082 1888 3070 225 410 751 1089
11
1 5
4 1 6 10121
1 3
2 6 803
3 3 741
4 2 7 11104
1 5
3 8 690
2 5 137
3 6 148
4 3 8 20915

예제 출력 2

7187
5810
6333

노트

출처

University > KAIST > KAIST ICPC Mock Competition > 2025 KAIST 15th ICPC Mock Competition D번

University > MIT > The MIT Programming Contest > 2025-26 > MIT Team Contest 2 D번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /