#P15589. [KTSC 2026] 瞭望塔 / Observation Tower
[KTSC 2026] 瞭望塔 / Observation Tower
Problem Description
There are observation towers, numbered in order. The height of tower is , and its observation score is . Initially, .
For , we say that tower can be observed from tower if and only if for any , we have . Note that when , tower cannot be observed from tower .
When an observation operation is performed on some tower, the observation scores of all towers that can be observed from this tower will each increase by .
Now there are events, and each event is one of the following three types:
- Observe: given (), perform one observation operation on tower .
- Query: given (), compute .
- Shift: given (). For any , set .
An observe event is represented by an array ; a query event is represented by an array ; a shift event is represented by an array . Note that the array sizes of these three types of events are all different, so the event type can be distinguished by the array size.
Events occur in order , and event is denoted by .
Let the total number of query events be , numbered in the order they occur. Output the results of all query events.
Implementation Details
This is a function-style interactive problem. You do not need to, and should not, implement the main function.
You should implement the following function:
vector<long long> tower_events(vector<int> H, vector<vector<int>> E)
- : an integer array of length .
- : an integer array of length , representing the events.
- Return an integer array of length , where is the result of the -th query event.
- This function is called exactly once.
Input Format
The input format of the sample grader is as follows:
- Line : .
- Line : .
- For all :
- Line : .
Output Format
The sample grader outputs the answers in the following format:
- For all :
- Line : .
5 5
1 2 3 4 5
1 0
2 1 3
3 1 2 1
1 1
2 0 4
3
6
10 11
7 7 9 5 8 10 2 9 2 2
1 1
3 6 8 6
1 1
2 1 9
1 3
1 8
2 2 4
1 5
3 1 1 7
1 1
2 0 9
5
3
10
Hint
Constraints
- .
- .
- .
- For observe events, .
- For query events, .
- For shift events, , .
- After a shift event occurs, it is guaranteed that .
- There is at least one query event.
Subtasks
| ID | Score | Constraints |
|---|---|---|
| ; in all query events, | ||
| ; no shift events | ||
| in all observe events, ; in all shift events, ; shift events occur at most times | ||
| in all query events, ; in all shift events, and | ||
| no additional constraints |
Samples
Sample
Consider the following call:
tower_events([1, 2, 3, 4, 5], [[0], [1, 3], [1, 2, 1], [1], [0, 4]])
- After the first event, , .
- The result of the second event (i.e., query event ) is .
- After the third event, , .
- After the fourth event, , .
- The result of the last event (i.e., query event ) is .
Therefore, this function should return .
Sample
Consider the following call:
tower_events([7, 7, 9, 5, 8, 10, 2, 9, 2, 2], [[1], [6, 8, 6], [1], [1, 9], [3], [8], [2, 4], [5], [1, 1, 7], [1], [0, 9]])
This function should return .
Translated by ChatGPT 5