Editorial for COCI '13 Contest 2 #1 Volim


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.

The solution to this task is to simulate the described game. For each query, the total game duration should be increased by the duration of that query. If the answer to that query was T, then the score of the player K should be increased by 1. (The emerging problem is what to do if the box reaches a player with a label greater than 8, which can be solved easily with remainders.)

We keep repeating this until the total game duration is less or equal to 210 seconds (3 minutes and 30 seconds). Notice that the events "incorrect" (N) and "skipped" (P) do not make change the player's turn and shouldn't be taken into account. From the task conditions, it is obvious that the query can continue even after the box has exploded. Notice that it is not a problem to end the program before all data has been read, what is important is the correct output. Take a look at the pseudocode for one of the possible solutions to this task.

input (K)
input (N)
game := 0 // game duration, initially zero

while (game <= 210) do
{
  input (T, Z)
  game := game + T // always increase game duration by T
  if (Z = 'T') and (game <= 210) then
    K = (K % 8) + 1
}
output(K)

Comments

There are no comments at the moment.