目录
1365E. Maximum Subsequence Value
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