#P2667. Tower Defense Damage Query

    ID: 15932 Type: Default 1000ms 256MiB

Tower Defense Damage Query

Tower Defense Damage Query

In this problem, you are given a simulation of attacks on the first defensive line in a tower defense game. The first defensive line consists of (n) defense units numbered from 1 to (n). Each unit initially has intact armor with an absorption threshold (T).

There are two types of operations:

  1. Attack Operation: Given an operation of the form

1 l r a

every defense unit in the range ([l, r]) is attacked. For a unit whose armor is intact, it receives (a) damage and the armor absorbs (a) damage. If after the attack the total absorbed damage is at least (T), the armor breaks. If the armor is already broken, the unit receives double damage (i.e. (2a)).

  1. Query Operation: Given an operation of the form

2 pos

output the total damage accumulated by the defense unit at position (pos) on the first line.

Note that the damage received during the attack that causes the armor to break is not doubled; only subsequent attacks on that unit (after the armor has broken) deal double damage.

Your task is to process (m) operations in the order they are given and output the result of each query operation.

inputFormat

The first line contains three integers (n), (m), and (T): the number of defense units, the number of operations, and the armor threshold respectively. The following (m) lines each describe an operation in one of the following formats:

• For an attack operation: 1 l r a   - This means that all defense units in the range [l, r] are attacked with power (a).

• For a query operation: 2 pos   - This asks for the current total damage on the defense unit at position (pos) of the first defensive line.

All indices are 1-indexed.

outputFormat

For each query operation, output a single line containing the total damage on the specified defense unit.

sample

5 5 10
1 1 3 4
2 2
1 2 5 7
2 3
2 1
4

11 4

</p>