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

31179번 - Paimon Segment Tree 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB533100.000%

문제

Paimon just learns the persistent segment tree and decides to practice immediately. Therefore, Lumine gives her an easy problem to start:

Given a sequence $a_1, a_2, \cdots, a_n$ of length $n,ドル Lumine will apply $m$ modifications to the sequence. In the $i$-th modification, indicated by three integers $l_i,ドル $r_i$ (1ドル \le l_i \le r_i \le n$) and $x_i,ドル Lumine will change $a_k$ to $(a_k + x_i)$ for all $l_i \le k \le r_i$.

Let $a_{i, t}$ be the value of $a_i$ just after the $t$-th operation. This way we can keep track of all historial versions of $a_i$. Note that $a_{i,t}$ might be the same as $a_{i,t-1}$ if it hasn't been modified in the $t$-th modification. For completeness we also define $a_{i, 0}$ as the initial value of $a_i$.

After all modifications have been applied, Lumine will give Paimon $q$ queries about the sum of squares among the historical values. The $k$-th query is indicated by four integers $l_k,ドル $r_k,ドル $x_k$ and $y_k$ and requires Paimon to calculate

$$\sum\limits_{i=l_k}^{r_k}\sum\limits_{j=x_k}^{y_k} a_{i, j}^2$$

Please help Paimon compute the result for all queries. As the answer might be very large, please output the answer modulo 10ドル^9 + 7$.

입력

There is only one test case in each test file.

The first line of the input contains three integers $n,ドル $m$ and $q$ (1ドル \le n, m, q \le 5 \times 10^4$) indicating the length of the sequence, the number of modifications and the number of queries.

The second line contains $n$ integers $a_1, a_2, \cdots, a_n$ ($|a_i| < 10^9 + 7$) indicating the initial sequence.

For the following $m$ lines, the $i$-th line contains three integers $l_i,ドル $r_i$ and $x_i$ (1ドル \le l_i \le r_i \le n,ドル $|x_i| < 10^9 + 7$) indicating the $i$-th modification.

For the following $q$ lines, the $i$-th line contains four integers $l_i,ドル $r_i,ドル $x_i$ and $y_i$ (1ドル \le l_i \le r_i \le n,ドル 0ドル \le x_i \le y_i \le m$) indicating the $i$-th query.

출력

For each query output one line containing one integer indicating the answer modulo 10ドル^9 + 7$.

제한

예제 입력 1

3 1 1
8 1 6
2 3 2
2 2 0 0

예제 출력 1

1

예제 입력 2

4 3 3
2 3 2 2
1 1 6
1 3 3
1 3 6
2 2 2 3
1 4 1 3
4 4 2 3

예제 출력 2

180
825
8

힌트

출처

Contest > Open Cup > 2021/2022 Season > Stage 9: Grand Prix of Nanjing E번

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

출처

대학교 대회

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

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