A10956 | Berzerk
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Rick and Morty are playing their own version of Berzerk (which has nothing in common with the famous Berzerk game). This game needs a huge space, so they play it with a computer.
In this game there are $n$ objects numbered from $1$ to $n$ arranged in a circle (in clockwise order). Object number $1$ is a black hole and the others are planets. There's a monster in one of the planet. Rick and Morty don't know on which one yet, only that he's not initially in the black hole, but Unity will inform them before the game starts. But for now, they want to be prepared for every possible scenario.
Each one of them has a set of numbers between $1$ and $n-1$ (inclusive). Rick's set is $s_{1}$ with $k_{1}$ elements and Morty's is $s_{2}$ with $k_{2}$ elements. One of them goes first and the player changes alternatively. In each player's turn, he should choose an arbitrary number like $x$ from his set and the monster will move to his $x$ -th next object from its current position (clockwise). If after his move the monster gets to the black hole he wins.
Your task is that for each of monster's initial positions and who plays first determine if the starter wins, loses, or the game will stuck in an infinite loop. In case when player can lose or make game infinity, it more profitable to choose infinity game.
In this game there are $n$ objects numbered from $1$ to $n$ arranged in a circle (in clockwise order). Object number $1$ is a black hole and the others are planets. There's a monster in one of the planet. Rick and Morty don't know on which one yet, only that he's not initially in the black hole, but Unity will inform them before the game starts. But for now, they want to be prepared for every possible scenario.
Each one of them has a set of numbers between $1$ and $n-1$ (inclusive). Rick's set is $s_{1}$ with $k_{1}$ elements and Morty's is $s_{2}$ with $k_{2}$ elements. One of them goes first and the player changes alternatively. In each player's turn, he should choose an arbitrary number like $x$ from his set and the monster will move to his $x$ -th next object from its current position (clockwise). If after his move the monster gets to the black hole he wins.
Your task is that for each of monster's initial positions and who plays first determine if the starter wins, loses, or the game will stuck in an infinite loop. In case when player can lose or make game infinity, it more profitable to choose infinity game.
输入格式
The first line of input contains a single integer $n$ ( $2<=n<=7000$ ) — number of objects in game.
The second line contains integer $k_{1}$ followed by $k_{1}$ distinct integers $s_{1,1},s_{1,2},...,s_{1,k1}$ — Rick's set.
The third line contains integer $k_{2}$ followed by $k_{2}$ distinct integers $s_{2,1},s_{2,2},...,s_{2,k2}$ — Morty's set
$1<=k_{i}<=n-1$ and $1<=s_{i,1},s_{i,2},...,s_{i,ki}<=n-1$ for $1<=i<=2$ .
The second line contains integer $k_{1}$ followed by $k_{1}$ distinct integers $s_{1,1},s_{1,2},...,s_{1,k1}$ — Rick's set.
The third line contains integer $k_{2}$ followed by $k_{2}$ distinct integers $s_{2,1},s_{2,2},...,s_{2,k2}$ — Morty's set
$1<=k_{i}<=n-1$ and $1<=s_{i,1},s_{i,2},...,s_{i,ki}<=n-1$ for $1<=i<=2$ .
输出格式
In the first line print $n-1$ words separated by spaces where $i$ -th word is "Win" (without quotations) if in the scenario that Rick plays first and monster is initially in object number $i+1$ he wins, "Lose" if he loses and "Loop" if the game will never end.
Similarly, in the second line print $n-1$ words separated by spaces where $i$ -th word is "Win" (without quotations) if in the scenario that Morty plays first and monster is initially in object number $i+1$ he wins, "Lose" if he loses and "Loop" if the game will never end.
Similarly, in the second line print $n-1$ words separated by spaces where $i$ -th word is "Win" (without quotations) if in the scenario that Morty plays first and monster is initially in object number $i+1$ he wins, "Lose" if he loses and "Loop" if the game will never end.
输入输出样例
输入 #1
5 2 3 2 3 1 2 3
输出 #1
Lose Win Win Loop Loop Win Win Win
输入 #2
8 4 6 2 3 4 2 3 6
输出 #2
Win Win Win Win Win Win Win Lose Win Lose Lose Win Lose Lose
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted