#P10540. [THUPC 2024 决赛] 古明地枣的袜子
[THUPC 2024 决赛] 古明地枣的袜子
Problem Description
You need to maintain a sequence .
You are given an operation sequence . An operation means adding to the values of .
There are queries. Each query gives and asks: starting from an initial sequence where all values are , execute the operations in order. What is the final value of ?
Input Format
The first line contains two integers ().
The next lines each contain two integers ().
The next lines each contain two integers ().
Output Format
Output lines, each containing one integer, which is the answer to each query.
6 5
6 4
2 6
5 -5
3 6
1 2
3 6
1 6
1 6
2 6
2 6
5 6
19
19
15
15
8
Hint
Source and Acknowledgements
From the THUPC2024 (2024 Tsinghua University Student Programming Contest and Intercollegiate Invitational) finals.
For testdata, statement, reference solution, editorial, etc., please refer to the official THUPC repository https://thusaac.com/public.
Translated by ChatGPT 5