This is a bilingual snapshot page saved by the user at 2025-4-30 19:19 for http://cxsjsx.openjudge.cn/2023hwall/019/, provided with bilingual support by Immersive Translate. Learn how to save?

OpenJudge

019: Warcraft Ultimate Edition

Total time limit:
6000ms
Memory limit:
65536kB
Description

The west of the World of Warcraft is the Red Devil Army's headquarters, and the east is the Blue Devil Army's headquarters. Between the two headquarters are several cities arranged in order, numbered 1, 2, 3...N from west to east (N <= 20). The Red Devil Army's headquarters is considered city number 0, and the Blue Devil Army's headquarters is considered city number N+1. The headquarters has life essence, which is used to manufacture warriors.

Both armies' headquarters manufacture warriors. There are five types of warriors: dragon, ninja, iceman, lion, and wolf. Each type of warrior has three attributes: number, health, and attack power.

The warrior numbers for both sides start from 1. The nth warrior created by the Red side has the number n. Similarly, the nth warrior created by the Blue side also has the number n.

Warriors have an initial health value when they are born. The health value changes during battle. If the health value is reduced to 0 (when the health value becomes negative, it should be treated as 0), the warrior dies (disappears).

Some warriors can possess weapons. There are three types of weapons: sword, bomb, and arrow, numbered 0, 1, and 2 respectively.

After a warrior is born, they will head towards the enemy headquarters. If they encounter an enemy in a city they pass through (at most one blue warrior and one red warrior can be in the same city at the same time), a battle will occur. Each battle only involves one side initiating an attack once. The attacked party's health will be reduced by the attacker's attack power plus the attack power of the sword in the attacker's hand. If the attacked party is not dead, they will launch a counterattack. The counterattacked party's health will be reduced by half (rounded down) of the counterattacker's attack power plus the attack power of the sword in the counterattacker's hand. The counterattack may lead to the enemy's death.

If a warrior kills an enemy in battle (whether by initiating the attack or by counterattack), their headquarters will immediately send them 8 life elements as a reward, increasing their health by 8. Of course, this is on the condition that the headquarters has 8 life elements. If the headquarters does not have enough life elements to reward all warriors, priority will be given to warriors closer to the enemy headquarters.

If a warrior kills an enemy in battle in a city, the warrior's headquarters immediately obtains all life elements in that city. Note that the headquarters always completes all reward work first and then begins to collect life elements from cities that have won battles. For warriors who do not receive rewards due to insufficient life elements in the headquarters, the headquarters will not retroactively issue rewards after obtaining spoils of life elements.

If a battle results in both sides surviving (a draw), neither side can take life essence from the city where the battle occurred.

Cities can have flags planted; initially, all cities have no flags. In cities with red flags planted, and in unflagged cities with odd numbers, red warriors initiate the attack. In cities with blue flags planted, and in unflagged cities with even numbers, blue warriors initiate the attack.

If a city has two consecutive battles where warriors from the same side kill their enemies (if there are several combat moments between the two battles where no combat occurs, the two battles are still considered consecutive; however, if there is a draw in between, they are not considered consecutive), then the city will be flagged with the winner's flag. If the city was previously flagged with the loser's flag, the loser's flag is removed. Once a flag is planted, it remains until replaced by the enemy. A city can have at most one flag at a time, and a flag will not be planted again with the same color until it has been replaced by the enemy.

Each weapon has its own characteristics:

The initial attack power of a sword is 20% (truncated) of the warrior's attack power. However, the sword becomes blunt after each battle (whether it's an active attack or a counterattack), and its attack power becomes 80% (truncated) of the previous battle's value. When the sword's attack power becomes 0, the warrior is considered to have lost the sword. If a warrior receives a sword with an initial attack power of 0 at birth, it is considered that the warrior does not have a sword.

An arrow has an attack power value R. If the next city to be reached has enemies, then the warrior with the arrow will shoot the enemies in the next city (cannot attack enemies in the opponent's headquarters) without being counterattacked. The arrow reduces the enemy's health by R. If the health is reduced to less than or equal to 0, the enemy is killed. The arrow is exhausted after being used 3 times, and the warrior loses the arrow. Two adjacent warriors may shoot each other to death simultaneously.

If a warrior with a bomb determines before the start of a battle that he will be killed (whether actively attacking the enemy or being actively attacked by the enemy may lead to his death, and it is assumed that the warrior can know the enemy's attack power and health), then he will use the bomb to kill himself and the enemy together. The warrior does not predict whether the opponent will use a bomb.

If a warrior uses a bomb to kill himself and the enemy, it does not count as a battle. Neither side can take the city's life elements, nor does it affect the city's flag.

Different warriors have different characteristics.

A dragon can possess one weapon. A dragon with serial number n is born with weapon number n%3. The dragon also has a "morale" attribute, which is a floating-point number whose value is the number of remaining life elements in its headquarters after it is born, divided by the number of life elements required to create the dragon. After a dragon actively engages in a battle, if it has not died and its morale value is greater than 0.8, it will cheer. Each time a dragon wins a battle (the enemy is killed), its morale increases by 0.2. Each time it experiences a battle it does not win, its morale decreases by 0.2. Morale increases and decreases occur before cheering.

A ninja can possess two weapons. A ninja with serial number n is born with weapons numbered n%3 and (n+1)%3. Ninjas never fight back when attacked.

An iceman has one weapon. An iceman with serial number n is born with weapon number n%3. Every two steps an iceman takes, at the completion of the second step, its life value decreases by 9 and its attack power increases by 20. However, if the life value would be less than or equal to 0 after subtracting 9, the life value does not decrease by 9, but instead becomes 1. That is, the iceman will not die from walking too much.

A lion has a "loyalty" attribute, the initial value of which is equal to the number of remaining life elements in its headquarters after it is born. After each battle in which it fails to kill an enemy, its loyalty decreases by K. If loyalty drops to 0 or below, the lion flees the battlefield and disappears forever. However, lions that have already reached the enemy's headquarters will not run away. Lions may run away at their own headquarters. If a lion dies in battle, its health before the battle is transferred to its opponent. "Before the battle" refers to the moment before the 40th minute of each hour.

A wolf has no weapon when it is born, but if it wins in battle (kills the enemy), it will seize the enemy's weapon, but it will not seize its own weapon. The seized weapon is of course not new; it is in whatever condition it was in when it was seized.

The following are the different events that occur at different times:

At each full hour, that is, at the 0th minute of each hour, a warrior is born in each of the two headquarters.

The red headquarters manufactures warriors in the order of iceman, lion, wolf, ninja, and dragon.

The blue headquarters manufactures warriors in the order of lion, dragon, ninja, iceman, and wolf.

Manufacturing warriors requires life elements.

To manufacture a warrior with an initial life value of m, the headquarters' life elements will be reduced by m.

If the headquarters does not have enough life essence to manufacture a warrior, the headquarters will wait until the first full hour after it has enough life essence to manufacture the warrior. For example, at 2:00, if the red headquarters was supposed to manufacture a wolf, but there is not enough life essence at that time, it will wait until the next full hour after there is enough life essence to manufacture the wolf.

At the 5th minute of each hour, the lion that is supposed to escape will escape at this moment.

At the 10th minute of each hour: all warriors move one step towards the enemy headquarters. That is, from one's own headquarters to an adjacent city, or from one city to the next city, or from a city adjacent to the enemy headquarters to the enemy headquarters.

At the 20th minute of each hour: each city produces 10 life essence. The life essence remains in the city until it is taken away by a warrior.

At the 30th minute of each hour: If there is only one warrior in a city, then that warrior takes all the life elements in the city and immediately transmits these life elements to its headquarters.

At the 35th minute of each hour, warriors with arrows shoot arrows, causing damage to the enemy. The arrow shooting event should be considered to have occurred in the city where the arrow was fired. Note that shooting arrows does not count as a battle, so the warrior shooting arrows will not receive any benefits. If a warrior is shot to death by an arrow in a city without enemies, it does not affect the changing of the flag in the city.

At the 38th minute of each hour, a warrior with a bomb evaluates whether to use the bomb. If so, he will use the bomb and die together with the enemy.

At the 40th minute of each hour: In cities with two warriors, a battle will occur. If the enemy has been shot to death by a flying arrow 5 minutes ago, it is still considered a battle, and the survivor is considered to have won the battle. In this case, there will be no "warrior actively attacks", "warrior counterattacks", or "warrior dies in battle" events, but the things that should happen after the victory of the battle will still happen. Like Wolf, it can seize weapons, the flag may also change, and so on. In this case, Dragon will also decide whether to cheer by judging whether it should be its turn to actively attack.

At the 50th minute of each hour, the headquarters reports the number of life elements it possesses.

At the 55th minute of each hour, each warrior reports the status of their weapons.

A warrior is considered to have completed their mission once they reach the opponent's headquarters, and they will stay there doing nothing from then on.

If there are 2 enemies in either side's headquarters, the headquarters is considered to have been captured by the enemy.

The war ends when the headquarters of either side is captured by the enemy. Nothing happens after the war ends.

Given a time, you are required to output all events from 0:00 to this time in chronological order. The events and their corresponding output examples are as follows:


1) Warrior birth

Output example: 000:00 blue lion 1 born

Indicates that at 0:00, the blue lion warrior with ID 1 is born.
If a dragon is created, an additional line should be output, for example:

000:00 blue dragon 1 born
Its morale is 23.34

Indicates that the morale of the dragon when it is born is 23.34 (rounded to two decimal places).

If a lion is created, then an additional line should be output, for example:
000:00 blue lion 1 born
Its loyalty is 24

Indicates that the loyalty of the lion at birth is 24.

2) lion escapes

Sample Output: 000:05 blue lion 1 ran away
Indicates that at 0:05, blue lion warrior number 1 ran away.

3) Warrior advances to a certain city

Sample output: 000:10 red iceman 1 marched to city 1 with 20 elements and force 30
Indicates that at 0:10, red warrior number 1, iceman, advanced to city number 1, at which point his health was 20 and his attack power was 30.
For iceman, the output health and attack power should be the changed values.

4) Samurai Archery

Output example: 000:35 blue dragon 1 shot
Indicates that at 0:35, the blue dragon warrior number 1 shot an arrow. If the arrow kills the enemy, the output should be as follows:
000:35 blue dragon 1 shot and killed red lion 4
At 0:35, blue dragon warrior number 1 shoots an arrow and kills red lion number 4.

5) Warrior uses bomb

Output example: 000:38 blue dragon 1 used a bomb and killed red lion 7
At 0:38, blue dragon warrior number 1 blew himself up with red lion number 7.

6) Warrior takes the initiative to attack

Output Sample: 000:40 red iceman 1 attacked blue lion 1 in city 1 with 20 elements and force 30
At 0:40, in city number 1, red warrior number 1 (iceman) attacked blue warrior number 1 (lion). Before launching the attack, red warrior number 1 (iceman) had 20 health points and an attack power of 30.

7) Warrior Counterattack

Output Sample: 001:40 blue dragon 2 fought back against red lion 2 in city 1
Indicates that at 1:40, in city 1, blue warrior No. 2 dragon counterattacked red warrior No. 2 lion

8) Warrior Dies in Battle

Output example: 001:40 red lion 2 was killed in city 1
Warriors killed by arrows will not have this output.

9) Warrior Cheers

Output example: 003:40 blue dragon 2 yelled in city 4

10) Warriors gain life elements

Output example: 001:40 blue dragon 2 earned 10 elements for his headquarter

Output does not include elements obtained outside of combat for 30 points

11) Flag Raised

Output Sample: 004:40 blue flag raised in city 4

12) The warrior arrives at the enemy headquarters

Output Sample: 001:10 red iceman 1 reached blue headquarter with 20 elements and force 30
(At this time, his health is 20 and his attack power is 30.) For iceman, the output health and attack power should be the changed values.

13) Headquarters occupied

Output example: 003:10 blue headquarter was taken

14) Headquarters report the number of life elements

000:50 100 elements in red headquarter
000:50 120 elements in blue headquarter
It means that at 0:50, the red headquarters has 100 life elements, and the blue side has 120.

15) Warrior reports weapon status

000:55 blue wolf 2 has arrow(2),bomb,sword(23)
000:55 blue wolf 4 has no weapon
000:55 blue wolf 5 has sword(20)
At 0:55, the blue warrior No. 2, wolf, has an arrow (which can be used 2 more times), a bomb, and a sword with an attack power of 23.
The blue warrior No. 4, wolf, has no weapons.
The blue warrior No. 5, wolf, has a sword with an attack power of 20.
When describing the weapons, the order is: arrow, bomb, sword. If there is no certain weapon, that weapon does not need to be mentioned. When reporting, first report all the red warriors from west to east, and then report all the blue warriors from west to east.

When outputting events:

Output in chronological order first;

Events that occur at the same time are output in order from west to east based on the location where they occur. The event of a warrior advancing is considered to have occurred at the destination.

Events 6 to 11 above may occur in a battle. These events are considered to occur simultaneously, and their time is the battle's start time. Among these events in a battle, the ones with smaller sequence numbers should be output first.

If two warriors arrive at the same city at the same time, output the Red warrior's advance event first, followed by the Blue warrior's.

Obviously, event #12 must have occurred an instant before event #13. When outputting, these two events are considered to occur at the same time, but event #12 should be output first.

Although nothing will happen after either headquarters is occupied, all events that occur at the same time as the headquarters being occupied must be output.

Input

The first line is t, representing the number of test data groups.
Each sample case consists of three lines.
The first line contains five integers M, N, R, K, and T. Their meanings are as follows:

Each headquarters initially has M life elements (1 <= M <= 10000)
There are a total of N cities between the two headquarters (1 <= N <= 20)
The attack power of the arrow is R
For each battle where the lion fails to kill the enemy, its loyalty decreases by K.
Output all events from 0:00 to time T (inclusive). T is in minutes, 0 <= T <= 5000.

The second line: five integers, which are the initial health values of dragon, ninja, iceman, lion, and wolf, in that order. They are all greater than 0 and less than or equal to 10000.

The third line: five integers, which are the attack powers of dragon, ninja, iceman, lion, and wolf, in that order. They are all greater than 0 and less than or equal to 10000.

Output

For each set of data, first output a line:
Case n:
For example, for the first set of data, output Case 1:
Then output all events that occurred up to time T in the appropriate order and format. Each event starts with the time it occurred, in the format "hour: minute", where "hour" has three digits and "minute" has two digits.

Sample Input
1
20 1 10 10 1000
20 20 30 10 20
5 5 5 5 5
Sample Output
Case 1:
000:00 blue lion 1 born
Its loyalty is 10
000:10 blue lion 1 marched to city 1 with 10 elements and force 5
000:30 blue lion 1 earned 10 elements for his headquarter
000:50 20 elements in red headquarter
000:50 20 elements in blue headquarter
000:55 blue lion 1 has no weapon
001:00 blue dragon 2 born
Its morale is 0.00
001:10 blue lion 1 reached red headquarter with 10 elements and force 5
001:10 blue dragon 2 marched to city 1 with 20 elements and force 5
001:30 blue dragon 2 earned 10 elements for his headquarter
001:50 20 elements in red headquarter
001:50 10 elements in blue headquarter
001:55 blue lion 1 has no weapon
001:55 blue dragon 2 has arrow(3)
002:10 blue dragon 2 reached red headquarter with 20 elements and force 5
002:10 red headquarter was taken
Global problem number
3433
Number of submissions
33
Number of attempts
10
Number of passes
9