#SRD0000113. Chef và Churu (Chef and Churu)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Chef và Churu (Chef and Churu)
Chef and Churu
Source: CodeChef
Version: Phuoc Hung OJ Extended
Problem Statement
Chef has an array of positive integers . He defines exactly functions:
$$F_i(A)=\sum_{j=L_i}^{R_i} A_j \qquad(1\le i\le N).$$The intervals never change; only the values in may change.
Process operations in their given order:
1 x y: assign (this is not an increment).2 m n: calculate using the current array.
An array value may contribute to multiple functions. The answer can exceed the maximum signed 64-bit integer.
Input
- The first line contains .
- The second line contains .
- The next lines give for each function .
- The next line contains .
- The final lines are operations
1 x yor2 m n.
All indices are 1-based. The parameters m n of a type-2 operation refer to function indices, not array positions.
Output
For each operation of type 2, output the requested sum on its own line as a decimal integer, without a modulus.
Subtasks
-
Subtask 1 (10 points, official): , ; ; ; an update has , and a type-2 query has .
-
Subtask 2 (10 points, official): ; ; and for every function; all positions used in type-1 updates are pairwise distinct; type-2 queries have .
-
Subtask 3 (80 points, official): ; ; ; type-1 positions can repeat, and type-2 queries have .
Examples
Example 1
Input
5
1 2 3 4 5
1 3
2 5
4 5
3 5
1 2
4
2 1 4
1 3 7
2 1 4
2 3 5
Output
41
53
28
Explanation
Initially , hence the first answer is . After assigning , these become ; the next answers are and .