Codeforces Round #648 (Div. 2) A、B、C、D、E、F题解

目录

1365A. Matrix Game

1365B. Trouble Sort

1365C. Rotation Matching

1365D. Solve The Maze

1365E. Maximum Subsequence Value

1365F. Swaps Again


1365A. Matrix Game

题意:给一个n*m的01矩阵,两人轮流将0转化为1,若点pos可以被转化,那么要求x行和y列没有1。谁不能转谁输。

思路:计算所有满足的点的数量,根据奇偶性判断。

AC代码:

/*---------------------------------
 *File name: A.cpp
 *Creation date: 2020-06-07 22:28
 *Link: 
 *-------------------------------*/
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define pb push_back
#define LL long long
#define PII pair<int, int>
#define Pque priority_queue 
using namespace std;
const int maxn = 1e5 + 5;
const int inf = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const double EPS = 1e-8;

int main(){
	int t;
	scanf("%d", &t);
	while(t--){
		int n, m;
		scanf("%d %d", &n, &m);
		vector<bool> col(m + 1, 0), row(n + 1, 0);
		for(int i = 1; i <= n; ++i){
			for(int j = 1; j <= m; ++j){
				int a;
				scanf("%d", &a);
				if(a){
					col[j] = 1;
					row[i] = 1;
				}
			}
		}
		int ans = 0;
		for(int i = 1; i <= n; ++i){
			for(int j = 1; j <= m; ++j){
				if(col[j] == 0 && row[i] == 0){
					ans++;
					col[j] = 1;
					break;
				}
			}
		}
		if(ans % 2 == 1){
			printf("Ashish\n");
		}
		else printf("Vivek\n");
	}
	return 0;
}

1365B. Trouble Sort

题意:给长度为为n的数组,每个数拥有属性(0或1),问是否能够将数组通过swap操作变为非递减数组,交换的两个数的属性必须不相同。

思路:想想就可以明白如果要排序属性为0的,只要有一个1 存在,就可以用这个1作为媒介交换两个0,反之也是这样,因此如果属性1和属性0的数都有,必定可以排序。如果0或1没有,那么直接判断原数组是否是非递减序列。

AC代码:

/*---------------------------------
 *File name: A.cpp
 *Creation date: 2020-06-07 23:17
 *Link: 
 *-------------------------------*/
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define pb push_back
#define LL long long
#define PII pair<int, int>
#define Pque priority_queue 
using namespace std;
const int maxn = 1e5 + 5;
const int in
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值