CF1365A.Matrix Game

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Ashish and Vivek play a game on a matrix consisting of nn rows and mm columns, where they take turns claiming cells. Unclaimed cells are represented by 00, while claimed cells are represented by 11. The initial state of the matrix is given. There can be some claimed cells in the initial state.

In each turn, a player must claim a cell. A cell may be claimed if it is unclaimed and does not share a row or column with any other already claimed cells. When a player is unable to make a move, he loses and the game ends.

If Ashish and Vivek take turns to move and Ashish goes first, determine the winner of the game if both of them are playing optimally.

Optimal play between two players means that both players choose the best possible strategy to achieve the best possible outcome for themselves.

阿希什和维韦克在一个包含 nn 行 mm 列的矩阵上进行一场游戏,双方轮流占据格子。未被占据的格子用 00 表示,已被占据的格子用 11 表示。矩阵的初始状态已给出,其中可能已存在一些已被占据的格子。

在每一轮中,玩家必须占据一个格子。一个格子可以被占据,当且仅当它当前未被占据,且其所在行与列均不包含任何其他已被占据的格子。当某位玩家无法进行合法操作时,该玩家判负,游戏结束。

若阿希什先手,维韦克后手,且双方均以最优策略进行游戏,请判断游戏的获胜者。

两人之间的最优策略意味着:双方均采用最有利于自身获得最佳结果的策略。

输入格式

The first line consists of a single integer tt (1≤t≤50)(1 \le t \le 50) — the number of test cases. The description of the test cases follows.

The first line of each test case consists of two space-separated integers nn, mm (1≤n,m≤50)(1 \le n, m \le 50) — the number of rows and columns in the matrix.

The following nn lines consist of mm integers each, the jj-th integer on the ii-th line denoting ai,ja_{i,j} (ai,j∈0,1)(a_{i,j} \in {0, 1}).

第一行包含一个整数 tt(1≤t≤501 \le t \le 50)—— 表示测试用例的数量。随后是各测试用例的描述。

每个测试用例的第一行包含两个以空格分隔的整数 nn、mm(1≤n,m≤501 \le n, m \le 50)—— 分别表示矩阵的行数和列数。

接下来的 nn 行中,每行包含 mm 个整数;其中第 ii 行的第 jj 个整数表示 ai,ja_{i,j}(ai,j∈{0,1}a_{i,j} \in \{0, 1\})。

输出格式

For each test case if Ashish wins the game print "Ashish" otherwise print "Vivek" (without quotes).

对于每个测试用例,如果阿西什赢得游戏,则输出 “Ashish”,否则输出 “Vivek”(不带引号)。

输入输出样例

  • 输入#1

    4
    2 2
    0 0
    0 0
    2 2
    0 0
    0 1
    2 3
    1 0 1
    1 1 0
    3 3
    1 0 0
    0 0 0
    1 0 0

    输出#1

    Vivek
    Ashish
    Vivek
    Ashish

说明/提示

For the first case: One possible scenario could be: Ashish claims cell (1,1)(1, 1), Vivek then claims cell (2,2)(2, 2). Ashish can neither claim cell (1,2)(1, 2), nor cell (2,1)(2, 1) as cells (1,1)(1, 1) and (2,2)(2, 2) are already claimed. Thus Ashish loses. It can be shown that no matter what Ashish plays in this case, Vivek will win.

For the second case: Ashish claims cell (1,1)(1, 1), the only cell that can be claimed in the first move. After that Vivek has no moves left.

For the third case: Ashish cannot make a move, so Vivek wins.

For the fourth case: If Ashish claims cell (2,3)(2, 3), Vivek will have no moves left.

第一种情况:一种可能的情形是:阿西什占据格子 (1,1)(1, 1),维韦克随后占据格子 (2,2)(2, 2)。此时,由于格子 (1,1)(1, 1) 和 (2,2)(2, 2) 已被占据,阿西什既无法占据格子 (1,2)(1, 2),也无法占据格子 (2,1)(2, 1)。因此阿西什失败。可以证明,在此情况下,无论阿西什如何行动,维韦克都将获胜。

第二种情况:阿西什占据格子 (1,1)(1, 1),这是第一步中唯一可占据的格子。此后维韦克已无合法操作可执行。

第三种情况:阿西什无法进行任何操作,因此维韦克获胜。

第四种情况:若阿西什占据格子 (2,3)(2, 3),则维韦克将无合法操作可执行。

输入解题思路,AI测评打分。不知道怎么写?

首页