#P4231. 三步必杀
三步必杀
Description
There are pillars in a row, and initially each pillar has damage .
Yuugi will perform attacks. Each attack is described by four parameters :
It means this attack affects all pillars from the -th to the -th (inclusive), dealing damage to the first pillar and to the last pillar within the range.
The damage values form an arithmetic progression. For example, if , then the damages to pillars are respectively.
The oni need the final damage of each pillar after all attacks are completed.
Input Format
The first line contains integers , separated by a space; same below.
Each of the next lines contains integers , as described above.
It is guaranteed that every individual damage applied to any pillar is an integer.
Output Format
Because the output might be too large to print in full, to ensure you can indeed maintain all pillars’ damage, output two integers separated by a space: the XOR sum of all pillars’ final damages and the maximum of them.
(The XOR sum is the value obtained by bitwise XOR over all numbers.)
(The XOR operator in C++ is ^.)
5 2
1 5 2 10
2 4 1 1
3 10
6 2
1 5 2 10
2 4 1 1
3 10
Hint
Sample explanation:
Sample 1:
Damage from the first attack: .
Damage from the second attack: .
Final damage of each pillar after all attacks: .
Output the XOR sum and the maximum, which are .
Sample 2:
The sixth pillar is not hit, so the answer remains unchanged.
Constraints:
This problem is worth points, split into subtasks. means (score/testcase count).
- Fairy level : . Even fairies playing around could finish this job, right?
- Kappa level : . Can this replace my work?
- Tengu level : . Small tricks no longer suffice.
- Oni God level : No special restrictions. Time to really think.
These four parts of testdata do not overlap.
For all data: , , .
All input, output, and pillar damage values are always within .
Tip:
Due to various reasons, the time limit may be tight. C++ participants, please do not use cin for input.
by orangebird.
Translated by ChatGPT 5
京公网安备 11011102002149号