#P5506. Drone Combat Simulation
Drone Combat Simulation
Drone Combat Simulation
In this problem, you are given a set of drones engaged in a chaotic aerial battle. Each drone has 5 attributes: \(atk, def, mat, mdf, fix\), a current health value \(hp\), a position \((x,y,z)\), and two orientation values: a horizontal facing \(f\) (ranging from 0 to 7) and a vertical facing \(h\) (ranging from 0 to 4). The battle lasts for \(t\) timesteps.
At each timestep, the simulation consists of two phases:
- Movement Phase: All live drones simultaneously move one step in their current forward direction. The forward direction is determined by \(f\) and \(h\) as follows:
- If \(h = 0\) or \(h = 4\), the drone moves vertically only: for \(h=0\): \((0,0,-1)\); for \(h=4\): \((0,0,1)\).
- If \(h = 2\), the drone moves horizontally based on \(f\). The mapping from \(f\) to horizontal movement \((dx,dy)\) is given by:
\(f=0: (0, 1)\), \(f=1: (-1, 1)\), \(f=2: (-1, 0)\), \(f=3: (-1, -1)\), \(f=4: (0, -1)\), \(f=5: (1, -1)\), \(f=6: (1, 0)\), \(f=7: (1, 1)\).
The movement then is \((dx, dy, 0)\). - If \(h = 1\) or \(h = 3\), the drone moves horizontally using the same mapping as above but also changes altitude: for \(h=1\) the \(z\) decreases by 1 and for \(h=3\) the \(z\) increases by 1. That is, the movement is \((dx, dy, -1)\) for \(h=1\) and \((dx, dy, 1)\) for \(h=3\).
- Operation Phase: Then, each live drone (in increasing order of their IDs) performs one command for that timestep. The commands are represented by a single character, and each drone has a string of \(t\) commands. The commands are:
N
: No operation.U
/D
: Change the vertical orientation \(h\).U
increases \(h\) by 1 andD
decreases \(h\) by 1 if the resulting value is within \([0,4]\); otherwise, the command is ignored.L
/R
: Change the horizontal orientation \(f\).L
increases \(f\) by 1 (modulo 8) andR
decreases \(f\) by 1 (modulo 8).F
: Repair, which increases \(hp\) by the drone'sfix
value.A
: Bullet attack. The drone fires a bullet in its forward direction (computed with the current \(f\) and \(h\)). Among all drones (except itself) lying exactly on the ray starting one step ahead, the nearest drone is selected. If multiple drones occupy the same cell, only the one with the smallest ID is hit. The damage dealt is \(\max(0, atk - def)\) (i.e. if the difference is negative, no damage is inflicted). If a drone's \(hp\) drops to 0 or below, it is destroyed immediately.M
: Laser attack. The drone fires a laser in its forward direction that affects all drones along the ray (excluding those at the same cell as the shooter). Each affected drone receives damage of \(\max(0, mat - mdf)\). Destruction rules are the same as for the bullet.
The forward direction for a drone is computed based on its current \(f\) and \(h\) as described above.
The input gives the initial state of each drone and their command strings. After simulating \(t\) timesteps, output the final position and \(hp\) of each drone (in the order of their IDs), one drone per line.
Input Format: The first line contains two integers \(n\) and \(t\), representing the number of drones and the number of timesteps. The following \(n\) lines each contain 11 space-separated integers: atk def mat mdf fix hp x y z f h
for each drone. Then, \(n\) lines follow, each containing a string of length \(t\) (with no spaces) representing the sequence of commands for that drone.
Output Format: Output \(n\) lines. Each line should contain four integers: the final \(x\), \(y\), \(z\) coordinates and the final \(hp\) of the corresponding drone.
inputFormat
The input begins with two integers (n) and (t). Then, (n) lines follow, each with 11 integers:
atk def mat mdf fix hp x y z f h
After that, there are (n) lines, each containing a string of length (t) representing the commands for the corresponding drone.
outputFormat
Output (n) lines. Each line should contain four space-separated integers representing the final (x), (y), (z) coordinates and (hp) of the drone (in order of their ID).
sample
2 2
10 5 8 3 4 20 0 0 0 0 2
7 2 9 4 3 15 1 1 0 4 2
AN
NF
0 2 0 20
1 -1 0 18
</p>