A13615 | GameGame
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Koa the Koala and her best friend want to play a game.
The game starts with an array $a$ of length $n$ consisting of non-negative integers. Koa and her best friend move in turns and each have initially a score equal to $0$ . Koa starts.
Let's describe a move in the game:
- During his move, a player chooses any element of the array and removes it from this array, xor-ing it with the current score of the player. More formally: if the current score of the player is $x$ and the chosen element is $y$ , his new score will be $x \oplus y$ . Here $\oplus$ denotes [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR).
Note that after a move element $y$ is removed from $a$ .
- The game ends when the array is empty.
At the end of the game the winner is the player with the maximum score. If both players have the same score then it's a draw.
If both players play optimally find out whether Koa will win, lose or draw the game.
The game starts with an array $a$ of length $n$ consisting of non-negative integers. Koa and her best friend move in turns and each have initially a score equal to $0$ . Koa starts.
Let's describe a move in the game:
- During his move, a player chooses any element of the array and removes it from this array, xor-ing it with the current score of the player. More formally: if the current score of the player is $x$ and the chosen element is $y$ , his new score will be $x \oplus y$ . Here $\oplus$ denotes [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR).
Note that after a move element $y$ is removed from $a$ .
- The game ends when the array is empty.
At the end of the game the winner is the player with the maximum score. If both players have the same score then it's a draw.
If both players play optimally find out whether Koa will win, lose or draw the game.
输入格式
Each test contains multiple test cases. The first line contains $t$ ( $1 \le t \le 10^4$ ) — the number of test cases. Description of the test cases follows.
The first line of each test case contains the integer $n$ ( $1 \le n \le 10^5$ ) — the length of $a$ .
The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ( $0 \le a_i \le 10^9$ ) — elements of $a$ .
It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$ .
The first line of each test case contains the integer $n$ ( $1 \le n \le 10^5$ ) — the length of $a$ .
The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ( $0 \le a_i \le 10^9$ ) — elements of $a$ .
It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$ .
输出格式
For each test case print:
- WIN if Koa will win the game.
- LOSE if Koa will lose the game.
- DRAW if the game ends in a draw.
- WIN if Koa will win the game.
- LOSE if Koa will lose the game.
- DRAW if the game ends in a draw.
输入输出样例
输入 #1
3 3 1 2 2 3 2 2 3 5 0 0 0 2 2
输出 #1
WIN LOSE DRAW
输入 #2
4 5 4 1 5 1 3 4 1 0 1 6 1 0 2 5 4
输出 #2
WIN WIN DRAW WIN
In testcase $1$ of the first sample we have:
$a = [1, 2, 2]$ . Here Koa chooses $1$ , other player has to choose $2$ , Koa chooses another $2$ . Score for Koa is $1 \oplus 2 = 3$ and score for other player is $2$ so Koa wins.
$a = [1, 2, 2]$ . Here Koa chooses $1$ , other player has to choose $2$ , Koa chooses another $2$ . Score for Koa is $1 \oplus 2 = 3$ and score for other player is $2$ so Koa wins.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted