#P9141. [THUPC 2023 初赛] 乱西星上的空战
[THUPC 2023 初赛] 乱西星上的空战
Background
As everyone knows, in modern warfare on Luanxi Star, air superiority is very important. For this reason, people developed drone technology. Unfortunately, because Luanxi Star’s algorithmic level and communication capability in every sense are far too backward, these drones can only use independent, foolproof combat modes. These modes contain no randomness, so the outcome of a foolproof drone air battle can almost always be predicted before it starts.
In short, the foolproof unmanned fighter formations of the |\| Country and the () Country, which are at war with each other on Luanxi Star, have encountered each other in the airspace at their shared border. Now the militaries of both countries hope you can predict the result of this air battle.
Background
As everyone knows, in modern warfare on Luanxi Star, air superiority is very important. For this reason, people developed drone technology. Unfortunately, because Luanxi Star’s algorithmic level and communication capability in every sense are far too backward, these drones can only use independent, foolproof combat modes. These modes contain no randomness, so the outcome of a foolproof drone air battle can almost always be predicted before it starts.
In short, the foolproof unmanned fighter formations of the |\| Country and the () Country, which are at war with each other on Luanxi Star, have encountered each other in the airspace at their shared border. Now the militaries of both countries hope you can predict the result of this air battle.
Problem Description
Airspace and time
Due to the mysterious physical laws of Luanxi Star, time and space on Luanxi Star are not continuous. If we consider the moment when the encounter begins as time step , then for any time step , at both the start and the end of this time step, an object (a drone or a missile) can only be at a position of the form (i.e., an integer lattice point in the airspace).
Drones
Because the airspace is much larger than a drone, we can treat a drone as a point mass (although in reality they look very similar to ordinary airplanes on Earth).
Flight state
At each time step, the flight state of a drone can be described by the following three groups of parameters.
- The coordinate at the current time step .
- The direction vector at the current time step, with .
- Here, denotes the length of vector . Let , then .
- You can simply think of as the direction the nose of the aircraft points to.
- The lift-line direction at the current time step, with .
- You can simply think of as the unit normal vector of the plane of the aircraft, pointing from the belly to the back.
- Then and uniquely determine a “left-hand direction” .
Flight performance
Loosely speaking, an airplane usually has three control axes: pitch, roll, and yaw. Pitching down (negative stick) and pitching up (positive stick) correspond to the aircraft nose going downward and upward (i.e., keeping unchanged). Rolling is rotation around the flight direction axis (i.e., keeping unchanged). Yawing turns the nose left or right (i.e., keeping unchanged). Due to special design, these drones have no yaw axis and can only pitch and roll. It is easy to see that even with only pitch and roll, a drone can freely change and (while maintaining ).
The above pitch (positive stick or negative stick), roll operations, straight flight, and their combinations are collectively called “maneuvers”.
Because of differences in drone models, a drone’s flight performance can be described by the following three groups of parameters. For convenience, in this section, let the parameters before one maneuver be , and after one maneuver be .
- Positive-stick rate and negative-stick rate .
- If the drone performs only a positive-stick maneuver, then it must satisfy $\vec p=\vec p',\vec l=\vec l',\vec u\cdot \vec d'\ge 0$. The time cost is .
- If the drone performs only a negative-stick maneuver, then it must satisfy $\vec p=\vec p',\vec l=\vec l',\vec u\cdot \vec d'\le 0$. The time cost is .
- Roll rate .
- If the drone performs only a roll maneuver, then it must satisfy . The time cost is .
- Maximum flight speed .
- If the drone performs only straight flight, then it must satisfy . The time cost is .
Legal movement
At each time step, if a drone can start from flight state and perform maneuvers strictly in the order roll, pitch (positive-stick or negative-stick), and straight flight, reaching a new flight state $\vec p'=(x',y',z')\not=\vec p,\vec d',\vec u',\vec l'$ such that , and the sum of time costs of all maneuvers is at most , then this is called one (drone) legal composite maneuver.
If a drone can, from , perform one legal composite maneuver to reach $\vec p'=(x',y',z')\not=\vec p,\vec d',\vec u',\vec l'$, and among all legal composite maneuvers that reach , this one has the minimum total time cost, then this is called a (drone) legal movement (or the movement is legal). In this case, the drone moves along a straight line from to . Unless stated otherwise, “movement” below is assumed (and should be) a legal movement.
Cobra maneuver
At each time step, regardless of the drone’s flight performance, a drone can always use the Cobra maneuver to change from flight state to $\vec p'=\vec p,\vec d'=\vec u,\vec u'=-\vec d,\vec l'=\vec l$. Note that this maneuver is not considered a legal maneuver.
Other parameters
In addition, a drone has the following parameters.
- Drone ID (abbreviated as “ID”).
- It is guaranteed that any two drones have different IDs.
- Faction (abbreviated as “faction”).
- The faction must be either the |\| Country or the () Country, and they regard each other as enemies.
Crash
A drone crashes if and only if it meets at least one of the following conditions.
- During the movement of some activated missile, its distance to that missile is not greater than the missile’s proximity detonation distance (see below).
- After some missile finishes its movement, it is at the same position as that missile (so the missile directly hits the drone; same below).
- During the drone’s movement, there exists at least one activated missile such that its distance to the drone is not greater than that missile’s proximity detonation distance.
- After the drone finishes its movement, there exists at least one missile whose position coincides with it.
- After the drone finishes its movement, there exists another drone at the same coordinate (so they collide and both crash).
After a drone crashes, it disappears immediately. After that, it will not launch missiles and will not cause other drones to crash. However, missiles already launched by it do not disappear or explode immediately.
In this case, we also say the drone is destroyed.
Air-to-air infrared guided missiles
Similarly, an air-to-air infrared guided missile (hereafter “missile”) can also be treated as a point mass, and its flight state and flight performance can be described as well.
Flight state
Because a missile has no notion of up/down/left/right, only the following two groups of parameters are needed to describe its flight state.
- The coordinate at the current time step .
- The direction vector at the current time step, with .
- You can simply think of as the direction the missile’s warhead points to.
Flight performance
Also because a missile has no notion of up/down/left/right, it has no pitch, roll, or yaw axes. Its ability to change is the same in all directions, and the operation of changing only is collectively called “yaw”. This and straight flight, and their combinations, are collectively called “maneuvers”.
Thus, a missile’s flight performance can be described by the following two groups of parameters. For convenience, in this section, let the parameters before one maneuver be , and after one maneuver be .
- Yaw rate .
- If the missile performs only yaw, then it must satisfy . The time cost is .
- Maximum flight speed .
- If the missile performs only straight flight, then it must satisfy . The time cost is .
Legal movement
At each time step, if a missile can start from flight state and perform maneuvers strictly in the order yaw and straight flight, reaching a new flight state such that , and the sum of time costs of all maneuvers is at most , then this is called one (missile) legal movement (or the movement is legal). In this case, the missile moves along a straight line from to . Unless stated otherwise, “movement” below is assumed (and should be) a legal movement.
Other parameters
In addition, a missile has the following parameters.
- Safety distance and activation status.
- Immediately after being launched, a missile is inactive.
- At the end of each time step, if a missile is inactive and either the drone that launched it has already crashed, or its distance to the launching drone is greater than the safety distance , then it becomes activated. After that it stays activated, and we say it is activated, or that it is an activated missile.
- Proximity detonation distance .
- During each missile movement, when an activated missile is within distance of any drone (including the launching drone), the missile enters the proximity-detonatable state (see “Explosion, disappearance, and proximity-detonatable” below).
- During each drone movement, if there exists a drone within distance of an activated missile, then the missile also enters the proximity-detonatable state.
- Maximum lock angle .
- At any time, a missile with flight state and maximum lock angle can lock onto a drone at if and only if and .
- In this case, we say the drone can be locked by the missile, or that it is within the missile’s lock range.
- We call the lock angle.
- Guidance time .
- If a missile is launched at time step , then by the end of time step , if it has still not exploded, it disappears immediately (see “Explosion, disappearance, and proximity-detonatable”). In this case, we say the missile exceeds its guidance time.
Explosion, disappearance, and proximity-detonatable
A missile explodes and disappears immediately when all of the following conditions hold.
- Before the missile movement starts, the missile is activated.
- One of the following conditions holds.
- During this missile movement, there exists a drone at such that $\min_{\lambda\in[0,1]}\|\lambda \vec p+(1-\lambda)\vec p'-\vec q\|\le d_p$, where are the start and end points of this missile movement.
- In this case, all such drones are destroyed by this missile. Also, a drone may be destroyed by multiple missiles simultaneously.
- During a drone movement, there exists a drone that moves from to , satisfying $\min_{\lambda\in[0,1]}\|\lambda \vec q+(1-\lambda)\vec q'-\vec p\|\le d_p$, where is the missile’s current position.
- In this case, all such drones are destroyed by this missile. Also, this missile may destroy multiple such drones simultaneously.
- During this missile movement, there exists a drone at such that $\min_{\lambda\in[0,1]}\|\lambda \vec p+(1-\lambda)\vec p'-\vec q\|\le d_p$, where are the start and end points of this missile movement.
In this case, we say the missile is proximity-detonatable, or the missile enters the proximity-detonatable state.
A missile does not explode but disappears at the end of the current time step when it meets at least one of the following conditions.
- The missile loses lock (see “Missile losing lock” below), and it was already activated at the start of the current time step.
- The missile exceeds its guidance time.
- The missile is inactive, and after the missile finishes its movement, its position coincides with a drone.
- In this case, the drone is destroyed by this missile. Also, a drone may be destroyed by multiple missiles simultaneously.
- The missile is inactive, and after a drone finishes its movement, this missile’s position coincides with a drone.
- In this case, the drone is destroyed by this missile. Also, one missile may destroy multiple such drones simultaneously.
Drone vision, radar search, and missile lock
Drone vision
At any time, a drone with flight state can spot a drone at if and only if . In this case, we say the drone at is within the vision of the drone at .
Onboard radar search range
A drone’s onboard radar (hereafter “radar”) scan range can be described by the following two parameters.
- Horizontal scan range and vertical scan range .
- At any time, a drone with flight state and radar scan range can scan a drone at if and only if and and .
- That is, if we build a plane with as the origin and as the axes, then the projection of onto this plane should lie within .
- In this case, we say the drone at is within the radar scan range of the drone at .
Missile losing lock
After a drone finishes its movement, if the missile’s chosen target has already crashed, or it cannot be locked by this missile, then we say the missile loses lock, or is in the lost-lock state.
After that it stays in the lost-lock state forever, regardless of whether the previously chosen drone later becomes lockable again.
Drone target selection strategy
At any time, a drone (hereafter “our drone”, same below) chooses a target drone according to the following strategy.
- If there is no enemy-faction drone (hereafter “enemy drone”, same below) within our drone’s vision, then our drone has no selected target.
- Otherwise, if the drone selected by our drone in the previous time step is still within our drone’s vision, then our drone keeps selecting that target.
- Otherwise, if there exists at least one enemy drone within our drone’s radar scan range, then choose the one with the smallest distance to our drone. If the closest enemy drone is not unique, choose the one with the smallest ID.
- Otherwise, for an enemy drone within vision at , let $\alpha=\alpha(\vec p;\vec l,\vec u),\vec r=P(\vec p';\alpha)=(r_x,r_y)$, then choose the one minimizing $\min\{|r_x-L_x|,|r_x+L_x|\}+\min\{|r_y-H_y|,|r_y+H_y|\}$. If there are multiple minima, also choose the one with the smallest ID.
Flight strategy
Drone flight strategy
Suppose the drone’s flight state is , its maximum flight speed is , and its radar scan range is .
- If the drone has a selected target at .
- If the drone can legally move to some position such that the enemy drone’s current position is still within our drone’s vision, then the drone legally moves to a flight state such that the enemy drone’s current position is still within our drone’s vision, and is minimized.
- If there are multiple such positions, let $\alpha_q=\alpha(\vec q;\vec l_q,\vec u_q),\vec r_q=P(\vec p';\alpha_q)=(r_{qx},r_{qy})$. Prefer positions that make $\vec r_q=(r_{qx},r_{qy})\in[-L_x,L_x]\times [-H_y,H_y]$.
- If there are still multiple such positions, choose the one minimizing .
- If there are still multiple such positions, choose the lexicographically smallest .
- If no such exists, choose the position minimizing $\min\{|r_{qx}-L_x|,|r_{qx}+L_x|\}+\min\{|r_{qy}-H_y|,|r_{qy}+H_y|\}$.
- If there are still multiple such positions, choose the lexicographically smallest .
- If there are multiple such positions, let $\alpha_q=\alpha(\vec q;\vec l_q,\vec u_q),\vec r_q=P(\vec p';\alpha_q)=(r_{qx},r_{qy})$. Prefer positions that make $\vec r_q=(r_{qx},r_{qy})\in[-L_x,L_x]\times [-H_y,H_y]$.
- Otherwise, the drone legally moves to some position that minimizes .
- If there are multiple such positions, choose the lexicographically smallest .
- If the drone can legally move to some position such that the enemy drone’s current position is still within our drone’s vision, then the drone legally moves to a flight state such that the enemy drone’s current position is still within our drone’s vision, and is minimized.
- Otherwise, the drone performs the Cobra maneuver to change its flight state to .
It is guaranteed that in case 1. above, the drone can always legally move to some position.
Missile flight strategy
Suppose the missile’s current flight state at this time step is , and the selected enemy drone’s flight state is .
If the missile had not lost lock by the end of the previous time step, let be the position where the enemy drone will move to in the next time step according to its flight strategy.
If the missile can legally move to , then it moves directly to .
Otherwise, it legally moves to a position such that the enemy drone’s post-movement position is within lock range, and is minimized.
- If there are multiple such , choose the one with the smallest lock angle after movement.
- If there are still multiple possibilities, choose the lexicographically smallest .
If no such position exists, or if the missile had already lost lock by the end of the previous time step, then the missile legally moves to some position that minimizes .
It is guaranteed that the missile can always legally move to some position.
Rules for drones launching missiles
A drone with flight state (hereafter “our drone”) launches a missile at the target drone (hereafter “enemy drone”) at selected by our drone according to the following rule.
At the start of each time step, if the selected enemy drone is already within our drone’s radar scan range, and there is currently no missile launched by our drone that has not exploded (or disappeared), then it launches an inactive missile with initial flight state $\vec p,\vec d=\dfrac{\vec p'-\vec p}{\|\vec p'-\vec p\|}$, and this missile selects the enemy drone.
Order of events within the same time step
- All drones select targets and determine the flight strategy for this time step.
- All drones that can launch missiles launch missiles.
- All missiles determine their flight strategy and move; during this process, some drones may be destroyed.
- All proximity-detonatable missiles explode and disappear.
- All drones move according to the flight strategy determined in 1.; during this process, some drones may be destroyed.
- All proximity-detonatable missiles explode and disappear.
- All drones at the same position collide and crash.
- All missiles that exceed guidance time, and lost-lock missiles that are activated, disappear.
- All missiles that can be activated become activated.
Task
Given, at the beginning of the airspace (i.e., at the start of time step ), the flight performance and state of each drone, and the flight performance of missiles, assuming this air battle will last for time steps, the commanders of both sides want you to output, in time order, all important events that occur at each time step.
Input Format
The first line contains two positive integers , indicating there are drones in total, and we simulate the first time steps. Among them, the first drones belong to the |\| Country, and the last drones belong to the () Country.
Next are groups of data. The -th group describes the drone with ID and contains multiple lines.
In each group:
The first line contains three integers representing . It is guaranteed that all are pairwise distinct, and the absolute value of each coordinate does not exceed .
The second line contains six integers representing the drone’s in order. It is guaranteed that .
- Here, $S_v=\{(1,0,0),(-1,0,0),(0,1,0),(0,-1,0),(0,0,1),(0,0,-1)\}$.
The third line contains six real numbers representing the drone’s in order.
The fourth line contains five real numbers and one positive integer representing the missile’s in order.
Output Format
Output groups of data. The -th group represents the important events that occur in time step .
In each group:
The first line contains three non-negative integers , representing the number of drones destroyed during the missile movement in this time step, the number of drones destroyed during the drone movement in this time step, and how many groups of drones crash in pairwise collisions due to sharing the same position at the end of this time step.
Next, output lines. Each line is in the form , meaning the drone with ID is destroyed during the missile movement in this time step, and in this process, there are missiles that destroyed this drone, launched by drones with IDs .
To ensure uniqueness of output, within each of these lines, must be output in increasing order, and the lines must be ordered by increasing .
Next, output lines. Each line is in the form , meaning the drone with ID is destroyed during the drone movement in this time step, and in this process, there are missiles that destroyed this drone, launched by drones with IDs .
To ensure uniqueness of output, within each of these lines, must be output in increasing order, and the lines must be ordered by increasing .
Next, output lines. Each line is in the form , meaning that at the end of this time step, there are drones at the same position, and their IDs are .
To ensure uniqueness of output, within each of these lines, must be output in increasing order, the lines must be ordered by increasing , and each ID appears at most once.
1 1
0 0 0
1 0 0 0 0 1
1 1 1 4 1 1
1 3 1 1 1 1
8 0 0
-1 0 0 0 0 1
1 1 1 4 1 1
1 3 1 1 1 1
0 0 1
2 1 2
1 4
0 0 0
1 0 0 0 0 1
1 1 1 3 1 1
1 15 3 2 1 10
60 0 0
-1 0 0 0 0 1
1 1 1 3 1 1
1 15 3 2 1 10
0 0 0
0 0 0
0 0 0
0 2 0
1 1 2
2 1 1
Hint
Sample Explanation 1
At time step , two airplanes collide at .
Sample Explanation 2
At time step , two missiles destroy the enemy aircraft respectively.
Constraints
.
The total number of drones and missiles with does not exceed .
$\theta_u,\theta_d,\gamma,\theta_r,\beta_s\in(\dfrac\pi4,\dfrac\pi2)$.
.
.
.
All real numbers in the input are precise to at most digits after the decimal point.
Initially, all are pairwise distinct.
Source
From the 2023 Tsinghua University Programming Contest and Intercollegiate Invitational (THUPC2023) Preliminary Round.
Resources such as editorials can be found at https://github.com/THUSAAC/THUPC2023-Pre.
Translated by ChatGPT 5