#P9381. Turn-Based Battle Simulation
Turn-Based Battle Simulation
Turn-Based Battle Simulation
In this problem, you are given two teams – the South team and the North team – each consisting of at most 6 members. Each member is characterized by several attributes: race, level, HP_max (which is also the initial HP), base attack index, base defense index, and a weapon’s attack power. In this simplified simulation, all actions are ordinary attacks.
The battle is turn‐based. In odd-numbered rounds, a member from the South team takes an action; in even-numbered rounds, a North team member takes an action. Within each team the acting member is chosen as follows:
- In the first action of that team (i.e. round 1 for South and round 2 for North), the member with the smallest id (among those still alive) acts.
- On subsequent turns, if there is any member with an id greater than the id of the member who acted last from that team (and is still alive), then the member with the smallest such id acts; otherwise, the living member with the smallest id acts.
When a member acts, they attack an enemy by selecting the enemy with the smallest id (among those still alive). The damage dealt is determined by the following formula:
$$damage = \left\lfloor \frac{\text{attacker\_base\_atk} \times \text{weapon\_attack}}{\text{defender\_base\_def}} \right\rfloor, $$where the floor operation is denoted by $$\lfloor \cdot \rfloor$$. (Note: Team attack/defense bonuses, skill bonuses, race bonus, and directional bonuses are all set to 1 in this simplified simulation.)
A member dies (is considered down) as soon as their HP becomes less than or equal to 0, and they can no longer act. The simulation proceeds until all members of one team have been knocked down. Your task is to simulate the battle and output the winning team – either "South" or "North".
All formulas with fractions and the floor function are written in LaTeX.
inputFormat
The first line contains two integers N and M representing the number of members in the South team and the North team respectively.
Then follow N lines, each describing a South team member. Each line contains 7 space‐separated values:
- id (an integer)
- race (a string; not used in simulation)
- level (an integer; not used in simulation)
- HP_max (an integer, also the initial HP)
- base attack index (an integer)
- base defense index (an integer)
- weapon attack (an integer)
Then follow M lines for the North team in the same format.
Note: You may assume that all teams have at least one member and that 1 ≤ N, M ≤ 6.
outputFormat
Output a single line with the winning team's name, which will be either "South" or "North".
sample
2 2
1 Weak 1 50 30 10 2
3 Average 1 60 25 12 3
2 Strong 1 55 28 11 2
4 Weak 1 45 35 15 4
South