A13873 | Nim Shortcuts
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 $(x_1, y_1), \ldots, (x_n, y_n)$ . 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 $(x_i, y_i)$ , 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.
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 $(x_1, y_1), \ldots, (x_n, y_n)$ . 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 $(x_i, y_i)$ , 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.
输入格式
The first line contains two integers $n$ and $m$ ( $1 \leq n, m \leq 10^5$ ) — 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 $x_i, y_i$ ( $0 \leq x_i, y_i \leq 10^9$ ). 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 $a_i, b_i$ ( $0 \leq a_i, b_i \leq 10^9$ ) — 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.
The following $n$ lines describe shortcut positions. The $i$ -th of these lines contains two integers $x_i, y_i$ ( $0 \leq x_i, y_i \leq 10^9$ ). 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 $a_i, b_i$ ( $0 \leq a_i, b_i \leq 10^9$ ) — 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.
输出格式
For each initial position, on a separate line print "WIN" if the starting player is able to win from this position, and "LOSE" otherwise.
输入输出样例
输入 #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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted