Editorial for DMOPC '19 Contest 5 P2 - Charlie's Crazy Conquest
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Let
Pseudocode:
Copy
read N, H
charlie.health is bot.health is H
for i in [0, N)
read l[i * 2].action, l[i * 2].amount
for i in [0, N)
read l[i * 2 + 1].action, l[i * 2 + 1].amount
player is charlie
opponent is bot
for move in l
if move.action is attack and (last_move.action is not dodge or no last_move)
subtract move.amount from opponent.health
else if next_move.action is dodge or no next_move
subtract move.amount from player.health
if charlie.health < 0 print "DEFEAT", terminate
if bot.health < 0 print "VICTORY", terminate
swap player with opponent
print "TIE"
Time complexity:
Comments