DMPG '17 B3 - Heroes

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Roger is addicted to the game Fire Emblem Heroes! His main hero is Hector, who has hH health and deals dH damage per turn. Hector is up against a foe who deals dF damage per turn, and has hF health. However, Hector's special, Buckler, activates every 4th turn and negates all damage done against him in that turn, as well as continues to deal the regular amount of damage.

Given N of these enemies, can you find out who will come out victorious if Hector attacks first, and how many turns it will take?

Note: assume the turn counter, as well as Hector's health, reset with each foe.

Constraints

Subtask 1 [60%]

1N1000

1hH,dH,hF,dF100

Subtask 2 [40%]

1N106

1hH,dH,hF,dF109

Input Specification

Line 1: Three space separated integers, N, hH, and dH.
Lines 2N+1: Two space separated integer, the hF and dF for each foe.

Output Specification

N lines, of the format Win x if Hector wins in x turns, or Lose x if Hector loses in x turns.

Sample Input

Copy
4 12 5
4 2
999 999
5 12
20 3

Sample Output

Copy
Win 1
Lose 1
Win 1
Win 4

Comments


  • 2
    geese  commented on Jan. 1, 2020, 12:53 a.m.

  • 5
    4fecta  commented on July 5, 2019, 2:57 a.m. edit 4

    Test cases are too weak. Most participants passed with brute force, while the time complexity for brute force is around O(N×min(Hh/Df,Hf/Dh)). This has a worst case of O(106×109), which is far too inefficient.

    Edit:

    Test case that cracks most submissions:

    Copy
    10 1000000000 1
    1000000000 1
    1000000000 1
    1000000000 1
    1000000000 1
    1000000000 1
    1000000000 1
    1000000000 1
    1000000000 1
    1000000000 1
    1000000000 1