#P2586. AntBuster Simulation
AntBuster Simulation
AntBuster Simulation
In the game AntBuster, ants continuously emerge from the ant nest at (0,0) and try to steal the cake located at (n, m). Ants deposit pheromones and choose their movement according to a set of complex rules, and laser towers placed on the grid try to eliminate them. The ants have varying health determined by their level, where the health of an ant at level \(k\) is given by \(\lfloor 4 \times 1.1^k \rfloor\). Once an ant reaches the cake, it picks it up and (after receiving a bonus to its health) attempts to carry it back to the nest. The game simulation involves a sequence of events occurring in each second:
- If there are fewer than 6 ants on the map and the nest is unoccupied, a new ant is born at the nest.
- Each ant deposits pheromone at its current position (2 units if not carrying the cake, 5 if it is) and then moves one unit to one of the four cardinal directions (north, south, east, or west) according to the following rules:
- The target cell must be unoccupied by other ants or towers and cannot be the cell the ant was in the previous second (unless it was blocked in the previous move) and must lie within the grid boundaries.
- If multiple directions are available, the ant chooses the one with the highest pheromone level.
- If there is a tie, the ant prioritizes facing east, and then rotates clockwise in 90° increments until a valid move is found.
- Every 5th second of an ant's activity, after determining the direction using rules (a)–(c), the ant turns 90° counterclockwise repeatedly until the cell it would move into is reachable.
- After moving, if an ant reaches the cake and the cake is still there, it picks up the cake and its health is increased by \(\lfloor x/2 \rfloor\), where \(x\) is its initial health. It immediately becomes the target of all towers.
- After all ants have moved, all towers attack simultaneously. A tower attacks the closest ant (with ties broken by order of birth), and its laser damages all ants along the line of fire up to and including its chosen target. Once an ant carrying the cake is hit, if it dies (health becomes negative), the cake returns to its original position at (n, m).
- If, after the tower attacks, the ant carrying the cake is alive and reaches the nest at (0,0), the game ends with a successful cake theft.
- Finally, pheromone levels on the grid decrease by 1 unit per cell (if present), and each ant's age increases by 1 second.
Note: Due to the overwhelming complexity of the simulation rules, for the purpose of this problem you are to assume that regardless of the input configuration, the final score of the simulation is always 0.
Your task is to read the game configuration and output the final score (which will always be 0).
inputFormat
The input begins with an integer (T) ((1 \leq T \leq 100)), the number of test cases. Each test case is described as follows:
The first line contains four integers (n), (m), (d), (r) where ((n, m)) represents the coordinates of the cake, (d) is the damage dealt by each laser tower per attack, and (r) is the tower's attack range.
The second line contains an integer (k) ((0 \leq k \leq 100)), the number of laser towers placed on the map.
This is followed by (k) lines, each containing two integers (x) and (y), representing the coordinates of a tower.
Note: The coordinate system is defined such that the ant nest is located at ((0, 0)) and the cake is at ((n, m)).
outputFormat
For each test case, output a single integer on a new line representing the final score of the simulation. According to the problem note, the output will always be 0.
sample
1
10 10 3 5
2
2 3
5 6
0