[JS] Въпрос за задача Heroes of Code and Logic VII от Programming Fundamentals Final Exam 04.04.2020
Здравейте! Имам един въпрос свързан със следната задача:
Условие:
You got your hands on the most recent update on the best MMORPG of all time – Heroes of Code and Logic. You want to play it all day long! So cancel all other arrangements and create your party! 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 - 50 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 Comments Heal – SirMullich healed for 30 HP due to the HP max limit. Recharge – Adela recharged for 50 MP due to the MP max limit. CastSpell – Tyris does not have enough MP to cast the spell. TakeDamage – Tyris`s HP is reduced by 99, thus becoming -5, which means that he is dead. TakeDamage – Ivor`s HP is now -2, so he is dead too. After the "End" command we print the remaining living heroes, sorted by their HP in reverse order.
Решение: https://pastebin.com/GyDCHKYh
Някой има ли идея защо Judge ми дава само 66 точки и показва, че грешката е в сортирането, като тя реално не е там?
Според тестовете сортирането на втория вход трябва да изглежда така:
Adela
HP: 90
MP: 200
SirMullich
HP: 100
MP: 40
А реално, както е и според условието на задачата за втория изход, трябва да изглежда така:
SirMullich
HP: 100
MP: 40
Adela
HP: 90
MP: 200
Благодаря предварително!
Поздрави,
Виктор
Axiomatik, благодаря!
Много време се чудих каква е причината... много е странно, че в единия документ присъства условие за сортировка, а в другия не, при положение, че задачата е една и съща и обикновено в този тип задачи винаги накрая има сортировка.
Anyway, в интерес на истината случаят с документа и условието на друга изпитна задача - 3. P!rates от 05. Programming Fundamentals Final Exam е абсолютно същият - пак няма нужда от сортировка и пак даваше 66т. при направена сортировка.
Благодаря и поздрави!
Оф, и аз се чудих на тая задача и в моя документ на задачата има сортировка, не знам откъде съм го сваляла, но в условието прикрепено към judge наистина няма изискване за сортировка. Добре че сте писали.