PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SRD0000055. Đảo đoạn và tính tổng (Range Reverse Range Sum)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đảo đoạn và tính tổng (Range Reverse Range Sum)
Range Reverse Range Sum
Source: Library Checker
Version: Phuoc Hung OJ Extended
Problem Statement
Given a sequence of nonnegative integers , process operations on half-open ranges :
0 l r: reverse the order of elements .1 l r: print .
Indices start at ; empty ranges () are valid and have sum zero. The array may be empty ().
Input
The first line contains , followed by the values (none if ). Each of the next lines is t l r with and .
Output
Print one sum per type-1 operation.
Subtasks
- Subtask 1 (10 points): ; . Zero-based, half-open intervals, allowing .
- Subtask 2 (20 points): ; . Zero-based, half-open intervals, allowing .
- Subtask 3 (30 points): ; . Zero-based, half-open intervals, allowing .
- Subtask 4 (40 points): ; . Zero-based, half-open intervals, allowing .
Examples
Input
4 5
1 2 3 4
1 1 3
0 2 4
1 0 3
0 4 4
1 0 0
Output
5
7
0
Explanation
Initially the sequence is . Query 1 1 3 sums . Reversing 0 2 4 gives , then 1 0 3 sums . The final empty-range sum is 0.