CF1458E.Nim Shortcuts
NOI/NOI+/CTSC
通过率:0%
时间限制:2.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
After your debut mobile game "Nim" blew up, you decided to make a sequel called "Nim 2". This game will expand on the trusted Nim game formula, adding the much awaited second heap!
In the game, there are two heaps, each containing a non-negative number of stones. Two players make moves in turn. On their turn, a player can take any positive number of stones from either one of the heaps. A player who is unable to move loses the game.
To make the game easier to playtest, you've introduced developer shortcuts. There are n shortcut positions (x1,y1),…,(xn,yn). These change the game as follows: suppose that before a player's turn the first and second heap contain x and y stones respectively. If the pair (x,y) is equal to one of the pairs (xi,yi), then the player about to move loses instantly, otherwise they are able to make moves as normal. Note that in the above explanation the two heaps and all pairs are ordered, that is, x must refer to the size of the first heap, and y must refer to the size of the second heap.
The game release was followed by too much celebration, and next thing you know is developer shortcuts made their way to the next official update of the game! Players now complain that the AI opponent has become unbeatable at certain stages of the game. You now have to write a program to figure out which of the given initial positions can be won by the starting player, assuming both players act optimally.
在你的首部手机游戏《Nim》爆火之后,你决定推出续作《Nim 2》。本作将在经典 Nim 游戏规则的基础上进行拓展,加入万众期待的第二堆石子!
游戏中有两堆石子,每堆包含若干(非负)颗石子。两名玩家轮流行动。在自己的回合中,一名玩家可以从任意一堆中取走任意正整数颗石子。无法行动的玩家判负。
为了便于游戏测试,你引入了开发者快捷方式(developer shortcuts)。共有 n 个快捷位置 (x1,y1),…,(xn,yn)。这些快捷方式会改变游戏规则如下:假设某玩家即将行动前,第一堆和第二堆分别含有 x 和 y 颗石子;若有序对 (x,y) 恰好等于某个快捷位置 (xi,yi),则该即将行动的玩家立即判负;否则,该玩家可照常进行操作。注意:上述描述中,两堆石子及所有快捷位置均为有序对,即 x 必须表示第一堆的石子数,y 必须表示第二堆的石子数。
游戏发布后庆祝过度,结果这些开发者快捷方式竟被误纳入了游戏的下一个正式更新!玩家们纷纷抱怨:AI 对手在游戏的某些阶段已变得无法战胜。你现在需要编写一个程序,判断所给的各个初始局面中,先手玩家在双方均采取最优策略的前提下,是否必胜。
输入格式
The first line contains two integers n and m (1≤n,m≤105) — the number of shortcut positions, and the number of initial positions that need to be evaluated.
The following n lines describe shortcut positions. The i-th of these lines contains two integers xi,yi (0≤xi,yi≤109). It is guaranteed that all shortcut positions are distinct.
The following m lines describe initial positions. The i-th of these lines contains two integers ai,bi (0≤ai,bi≤109) — the number of stones in the first and second heap respectively. It is guaranteed that all initial positions are distinct. However, initial positions are not necessarily distinct from shortcut positions.
第一行包含两个整数 n 和 m(1≤n,m≤105)—— 分别表示捷径位置的数量和需要评估的初始位置的数量。
接下来的 n 行描述捷径位置。其中第 i 行包含两个整数 xi,yi(0≤xi,yi≤109)。保证所有捷径位置互不相同。
接下来的 m 行描述初始位置。其中第 i 行包含两个整数 ai,bi(0≤ai,bi≤109)—— 分别表示第一堆和第二堆中的石子数量。保证所有初始位置互不相同。但初始位置与捷径位置之间不一定互不相同。
输出格式
For each initial position, on a separate line print "WIN" if the starting player is able to win from this position, and "LOSE" otherwise.
对于每个初始位置,单独一行输出:如果先手玩家能从该位置获胜,则输出“WIN”;否则输出“LOSE”。
输入输出样例
输入#1
3 5 3 0 0 1 2 2 0 0 1 1 2 2 3 3 5 4
输出#1
LOSE WIN LOSE WIN LOSE
输入解题思路,AI测评打分。不知道怎么写?