A13904 | Nullify The Matrix
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Jeel and Ashish play a game on an $n \times m$ matrix. The rows are numbered $1$ to $n$ from top to bottom and the columns are numbered $1$ to $m$ from left to right. They play turn by turn. Ashish goes first.
Initially, each cell of the matrix contains a non-negative integer. Each turn, a player must perform all of the following actions in order.
- Choose a starting cell $(r_1, c_1)$ with non-zero value.
- Choose a finishing cell $(r_2, c_2)$ such that $r_1 \leq r_2$ and $c_1 \leq c_2$ .
- Decrease the value of the starting cell by some positive non-zero integer.
- Pick any of the shortest paths between the two cells and either increase, decrease or leave the values of cells on this path unchanged. Note that:
- a shortest path is one that passes through the least number of cells;
- all cells on this path excluding the starting cell, but the finishing cell may be modified;
- the resulting value of each cell must be a non-negative integer;
- the cells are modified independently and not necessarily by the same value.
If the starting and ending cells are the same, then as per the rules, the value of the cell is decreased. No other operations are performed.
The game ends when all the values become zero. The player who is unable to make a move loses. It can be shown that the game will end in a finite number of moves if both players play optimally.
Given the initial matrix, if both players play optimally, can you predict who will win?
Initially, each cell of the matrix contains a non-negative integer. Each turn, a player must perform all of the following actions in order.
- Choose a starting cell $(r_1, c_1)$ with non-zero value.
- Choose a finishing cell $(r_2, c_2)$ such that $r_1 \leq r_2$ and $c_1 \leq c_2$ .
- Decrease the value of the starting cell by some positive non-zero integer.
- Pick any of the shortest paths between the two cells and either increase, decrease or leave the values of cells on this path unchanged. Note that:
- a shortest path is one that passes through the least number of cells;
- all cells on this path excluding the starting cell, but the finishing cell may be modified;
- the resulting value of each cell must be a non-negative integer;
- the cells are modified independently and not necessarily by the same value.
If the starting and ending cells are the same, then as per the rules, the value of the cell is decreased. No other operations are performed.
The game ends when all the values become zero. The player who is unable to make a move loses. It can be shown that the game will end in a finite number of moves if both players play optimally.
Given the initial matrix, if both players play optimally, can you predict who will win?
输入格式
The first line contains a single integer $t$ ( $1 \leq t \leq 10$ ) — the number of test cases. The description of each test case is as follows.
The first line of each test case contains two integers $n$ and $m$ ( $1 \leq n, m \leq 100$ ) — the dimensions of the matrix.
The next $n$ lines contain $m$ space separated integers $a_{i,j}$ ( $0 \leq a_{i,j} \leq 10^6$ ) — the values of each cell of the matrix.
The first line of each test case contains two integers $n$ and $m$ ( $1 \leq n, m \leq 100$ ) — the dimensions of the matrix.
The next $n$ lines contain $m$ space separated integers $a_{i,j}$ ( $0 \leq a_{i,j} \leq 10^6$ ) — the values of each cell of the matrix.
输出格式
For each test case, if Ashish wins the game, print "Ashish", otherwise print "Jeel" (without the quotes).
输入输出样例
输入 #1
4 1 1 0 1 3 0 0 5 2 2 0 1 1 0 3 3 1 2 3 4 5 6 7 8 9
输出 #1
Jeel Ashish Jeel Ashish
In the first test case, the only cell of the matrix is 0. There are no moves Ashish can make. Jeel is the winner.
In the second test case, Ashish can choose $(r_1, c_1) = (r_2, c_2) = (1,3)$ and reduce the cell to $0$ , leaving $[0, 0, 0]$ . Jeel cannot perform any moves. Ashish wins.
In the second test case, Ashish can choose $(r_1, c_1) = (r_2, c_2) = (1,3)$ and reduce the cell to $0$ , leaving $[0, 0, 0]$ . Jeel cannot perform any moves. Ashish wins.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted