题目链接:https://codeforces.com/contest/1365/problem/A
题意
给出一个 $n imes m$ 的网格,两人轮流选择一个所在行列没有 $1$ 的方块置为 $1$,判断最后谁会胜利。
题解
模拟一共能走多少步,奇数先手胜,偶数后手胜。
代码
#include <bits/stdc++.h> using namespace std; void solve() { int n, m; cin >> n >> m; bool row[n] = {}; bool col[m] = {}; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { int x; cin >> x; if (x == 1) row[i] = col[j] = true; } } int cnt = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (!row[i] and !col[j]) { row[i] = col[j] = true; ++cnt; } } } cout << (cnt & 1 ? "Ashish" : "Vivek") << " "; } int main() { int t; cin >> t; while (t--) solve(); }