Heaps
Time limit1.2sMemory limit1024 MB
Given N heaps of big stones and small pebbles, decide whether the first player wins when each removed stone must be replaced by at least K pebbles.
- Level
Medium7 of 10
- Topics
- Game theory, Math, Dynamic programming
- Solved
- No attempts yet
Problem
Nini and Mimi are playing a game with heaps of stones and pebbles. Each heap has big stones and small pebbles. The players take turns making moves, and a player who has no move left loses. A move chooses a non-empty heap and removes some stones and/or pebbles from it. Specifically, the player removes stones and pebbles, where , , and . Every removed stone must be replaced with at least pebbles. So when , the player first removes pebbles, then adds back pebbles from an infinite supply, where and is a natural number. Nini moves first. Before her move, she wants to know whether she can win if both players play optimally.
Input
The first line contains and . Then independent tests follow, all using the same . Each test starts with a line containing . The next lines each contain and for one heap.
Output
Print lines, one answer per test, in the input order. Print Win if Nini can win, and Loss otherwise.