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

19068번 - Sequence 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
7 초 512 MB68577326.324%

문제

Yuta has an array $A_1,ドル $A_2,ドル $\ldots,ドル $A_n$ with $n$ integers, and he keeps a copy of the initial contents of array $A$ as $A'$ (initially, $A'_i = A_i$). Then he executes $m$ operations on the array $A$.

There are three types of operations:

  • "1 $l$ $r$": Yuta wants to find the sum of $A_i$ for all $i$ in $[l, r]$.
  • "2 $l$ $r$ $k$": Yuta runs the following pseudocode on the sequence $A$: for (int i = l; i <= r; i++) A[i] = A[i - k];
  • "3 $l$ $r$": For all $i \in [l,r],ドル Yuta changes $A_i$ back to $A'_i$.

Help Yuta execute all the given operations.

입력

The first line of the input contains two integers $n$ and $m$ (1ドル \leq n, m \leq 2 \cdot 10^5$).

The second line contains $n$ integers $A_i$ (0ドル \leq A_i \leq 10^9$).

Then $m$ lines follow, each line describes an operation in the format shown above. It is guaranteed that 1ドル \le l \le r \le n$ and 1ドル \leq k < l$.

출력

For each operation of the first type, print a single line with a single integer: the required sum.

제한

예제 입력 1

5 7
1 2 3 4 5
1 1 5
2 3 4 1
1 1 5
2 3 4 2
1 1 5
3 1 5
1 1 5

예제 출력 1

15
12
11
15

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2017 > Day 4: Ruyi Ji Contest 2 C번

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

출처

대학교 대회

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

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