CF1451F.Nullify The Matrix
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Jeel and Ashish play a game on an n×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 (r1,c1) with non-zero value.
- Choose a finishing cell (r2,c2) such that r1≤r2 and c1≤c2.
- 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?
杰尔和阿西什在一个 n×m 的矩阵上进行一场游戏。行从上到下编号为 1 到 n,列从左到右编号为 1 到 m。他们轮流进行操作,阿西什先手。
初始时,矩阵的每个单元格中均包含一个非负整数。在每一轮中,玩家必须按顺序执行以下全部操作:
- 选择一个起始单元格 (r1,c1),其值为非零;
- 选择一个终止单元格 (r2,c2),满足 r1≤r2 且 c1≤c2;
- 将起始单元格的值减去某个正整数(即严格大于零的整数);
- 在两个单元格之间任选一条最短路径,并对这条路径上的所有单元格独立地执行以下三种操作之一:增加其值、减少其值、或保持不变。注意:
- 最短路径是指经过单元格数量最少的路径;
- 该路径上除起始单元格外的所有单元格(包括终止单元格)均可被修改;
- 每个单元格修改后的值必须仍为非负整数;
- 各单元格的修改量彼此独立,且不必相同。
若起始单元格与终止单元格相同,则根据规则,仅将该单元格的值减小(不执行其他任何操作)。
当矩阵中所有值均变为零时,游戏结束。无法进行合法操作的玩家判负。可以证明:若双方均采取最优策略,则游戏必将在有限步内结束。
给定初始矩阵,若双方均采用最优策略,你能判断谁将获胜吗?
输入格式
The first line contains a single integer t (1≤t≤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≤n,m≤100) — the dimensions of the matrix.
The next n lines contain m space separated integers ai,j (0≤ai,j≤106) — the values of each cell of the matrix.
第一行包含一个整数 t(1≤t≤10)—— 测试用例的数量。每个测试用例的描述如下:
每个测试用例的第一行包含两个整数 n 和 m(1≤n,m≤100)—— 矩阵的维度。
接下来的 n 行每行包含 m 个用空格分隔的整数 ai,j(0≤ai,j≤106)—— 矩阵中每个单元格的值。
输出格式
For each test case, if Ashish wins the game, print "Ashish", otherwise print "Jeel" (without the quotes).
对于每个测试用例,如果 Ashish 获胜,则输出 “Ashish”,否则输出 “Jeel”(不带引号)。
输入输出样例
输入#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 (r1,c1)=(r2,c2)=(1,3) and reduce the cell to 0, leaving [0,0,0]. Jeel cannot perform any moves. Ashish wins.
在第一个测试用例中,矩阵中唯一的单元格值为 0。Ashish 无法进行任何操作,Jeel 获胜。
在第二个测试用例中,Ashish 可以选择 (r1,c1)=(r2,c2)=(1,3),将该单元格的值减至 0,从而得到 [0,0,0]。Jeel 无法执行任何操作,Ashish 获胜。
输入解题思路,AI测评打分。不知道怎么写?