Heroes of Code and Logic VII
Здравейте, judge ми дава 93/100 точки. Ще съм благодарен ако някой има идея от къде идва грешката.
Код: https://pastebin.com/sap0e3BW
On the first line of the standard input you will receive an integer n – the number of heroes that you can choose for your party. On the next n lines, the heroes themselves will follow with their hit points and mana points separated by empty space in the following format:
{hero name} {HP} {MP}
- where HP stands for hit points and MP for mana points
- a hero can have a maximum of 100 HP and 200 MP
After you have successfully picked your heroes, you can start playing the game. You will be receiving different commands, each on a new line, separated by " – ", until the "End" command is given.
There are several actions that can be performed by the heroes:
CastSpell – {hero name} – {MP needed} – {spell name}
- If the hero has the required MP, he casts the spell, thus reducing his MP. Print this message:
- "{hero name} has successfully cast {spell name} and now has {mana points left} MP!"
- If the hero is unable to cast the spell print:
- "{hero name} does not have enough MP to cast {spell name}!"
TakeDamage – {hero name} – {damage} – {attacker}
- Reduce the hero HP by the given damage amount. If the hero is still alive (his HP is greater than 0) print:
- "{hero name} was hit for {damage} HP by {attacker} and now has {current HP} HP left!"
- If the hero has died, remove him from your party and print:
- "{hero name} has been killed by {attacker}!"
Recharge – {hero name} – {amount}
- The hero increases his MP. If a command is given that would bring the MP of the hero above the maximum value (200), MP is increased to 200. (the MP can’t go over the maximum value).
- Print the following message:
- "{hero name} recharged for {amount recovered} MP!"
Heal – {hero name} – {amount}
- The hero increases his HP. If a command is given that would bring the HP of the hero above the maximum value (100), HP is increased to 100 (the HP can’t go over the maximum value).
- Print the following message:
- "{hero name} healed for {amount recovered} HP!"
Input
- On the first line of the standard input you will receive an integer n
- On the next n lines, the heroes themselves will follow with their hit points and mana points separated by empty space in the following format
- You will be receiving different commands, each on a new line, separated by " – ", until the "End" command is given
Output
- Print all members of your party who are still alive, sorted by their HP in descending order, then by their name in ascending order, in the following format (their HP/MP need to be indented 2 spaces):
"{hero name}
HP: {current HP}
MP: {current MP}
..."
Constraints
- The starting HP/MP of the heroes will be valid, 32-bit integers, will never be negative or exceed the respective limits.
- The HP/MP amounts in the commands will never be negative.
- The hero names in the commands will always be valid members of your party. No need to check that explicitly
Examples
Input |
Output |
|
2 Solmyr 85 120 Kyrre 99 50 Heal - Solmyr - 10 Recharge - Solmyr - 80 TakeDamage - Kyrre - 66 - Orc CastSpell - Kyrre - 15 - ViewEarth End |
Solmyr healed for 10 HP! Solmyr recharged for 50 MP! Kyrre was hit for 66 HP by Orc and now has 33 HP left! Kyrre has successfully cast ViewEarth and now has 35 MP! Solmyr HP: 95 MP: 170 Kyrre HP: 33 MP: 35 |
|
Comments |
||
These are examples of successful actions. The different colors denote the commands and their respective messages. |
||
Input |
Output |
|
4 Adela 90 150 SirMullich 70 40 Ivor 1 111 Tyris 94 61 Heal - SirMullich - 50 Recharge - Adela - 100 CastSpell - Tyris - 1000 - Fireball TakeDamage - Tyris - 99 - Fireball TakeDamage - Ivor - 3 - Mosquito End |
SirMullich healed for 30 HP! Adela recharged for 50 MP! Tyris does not have enough MP to cast Fireball! Tyris has been killed by Fireball! Ivor has been killed by Mosquito! SirMullich HP: 100 MP: 40 Adela HP: 90 MP: 200 |
|