Codeforces648div2A

Codeforces648div2A

原题:

Ashish and Vivek play a game on a matrix consisting of n rows and m columns, where they take turns claiming cells. Unclaimed cells are represented by 0, while claimed cells are represented by 1. 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.

Input
The first line consists of a single integer t (1≤t≤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 n, m (1≤n,m≤50) — the number of rows and columns in the matrix.

The following n lines consist of m integers each, the j-th integer on the i-th line denoting ai,j (ai,j∈{0,1}).

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

思路:模拟,记录下每一行、每一列是否可选

ACcodes

#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
using namespace std;
int a[60][60];
void q()
{
	int n;
	scanf("%d",&n);
	long long int a=0;
	long long int tot = (1<<(n+1)) - 2;
	a = (1<<n) + (1<<(n/2)) -2;
	cout << abs(tot-2*a) << endl;
}
int main()
{
	int test=1;
	scanf("%d",&test);
	while(test--) {
		int n,m;cin>>n>>m;
		int cnt1=0,cnt2=0;
		for(int i=0;i<n;i++) {
			int flag = 0;
			for(int j=0;j<m;j++) {
				int x;cin>>x;
				if(x == 1) 
					flag = 1;
				a[i][j] = x;
			}
			if(flag == 0) cnt1++;
		}
		for(int i=0;i<m;i++) {
			int flag = 0;
			for(int j=0;j<n;j++) {
				if(a[j][i] == 1) flag = 1;
			}
			if(flag == 0) cnt2++;
		}
		int cnt = min(cnt1,cnt2);
		if(cnt%2==0) {
			cout<<"Vivek" << endl;
		} else {
			cout<<"Ashish" << endl;
		}
	}
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值