CF 1119C Ramesses and Corner Inversion
https://codeforces.com/problemset/problem/1119/C
题目
给两个矩阵,只能选宽和高大于等于2的子矩阵左上、左下、右上、右下四点翻转(1->0,0->1)
问能否经过一些操作将A翻转到B
题解
能当且仅当每行和每列不同的数量都为偶数。
必要性:一次翻转不改变奇偶性,所以必要性成立。
充分性:可以每次进行(0,0,x,y)的操作,将除了第一行和第一列的所有不同翻转为相同,因为是不同的数量是偶数,所以第一行和第一列也相同。(把不同看成1,相同看成0)
但是想不到啊……高中学的太差了
AC代码
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
#include<iomanip> #define REP(r,x,y) for(register int r=(x); r<(y); r++)
#define REPE(r,x,y) for(register int r=(x); r<=(y); r++)
#ifdef sahdsg
#define DBG(...) printf(__VA_ARGS__)
#else
#define DBG(...) (void)0
#endif using namespace std;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii; char ch; int f;
template <class T>
inline void read(T &x) {
x=0; f=1; do ch=getchar(); while(!isdigit(ch) && ch!='-');
if(ch=='-') ch=getchar(),f=-1; while(isdigit(ch)) {x=x*10+ch-'0';
ch=getchar();} x*=f;
} #define MAXN 507
int h[MAXN], l[MAXN];
int arr[MAXN][MAXN]; int main() {
int a,b; read(a), read(b);
REP(i,0,a) REP(j,0,b){
read(arr[i][j]);
}
REP(i,0,a) REP(j,0,b){
int t; read(t);
arr[i][j]^=t;
}
REP(i,0,a) REP(j,0,b) {
h[i]+=arr[i][j];
l[j]+=arr[i][j];
} REP(i,0,a)if(h[i]&1) {puts("no"); return 0;}
REP(j,0,b)if(l[j]&1) {puts("no"); return 0;}
puts("yes");
return 0;
}
CF 1119C Ramesses and Corner Inversion的更多相关文章
- CF1119C Ramesses and Corner Inversion
题目地址:CF1119C Ramesses and Corner Inversion 将两个矩阵异或起来,为 \(1\) 的位置就是需要修改的位置 注意到每一次操作都会导致两行和两列上有两个数被修改 ...
- cf-Global Round2-C. Ramesses and Corner Inversion(思维)
题目链接:http://codeforces.com/contest/1119/problem/C 题意:给两个同型的由0.1组成的矩阵A.B,问A能否经过指定的操作变成B,指定操作为在矩阵A中选定一 ...
- Global Round 2
A - Ilya and a Colorful Walk CodeForces - 1119A Ilya lives in a beautiful city of Chordalsk. There a ...
- Codeforces Global Round 2 Solution
这场题目设置有点问题啊,难度:Div.2 A->Div.2 B->Div.2 D->Div.2 C->Div.2 D->Div.1 D-> Div.1 E-> ...
- CF1119 Global Round 2
CF1119A Ilya and a Colorful Walk 这题二分是假的.. \(1,2,1,2,1\) 有间隔为 \(3\) 的,但没有间隔为 \(2\) 的.开始被 \(hack\) 了一 ...
- Codeforces Global Round 2部分题解
传送门 好难受啊掉\(rating\)了-- \(A\ Ilya\ and\ a\ Colorful\ Walk\) 找到最后一个与第一个颜色不同的,比一下距离,然后再找到最左边和最右边与第一个颜色不 ...
- Codeforces Global Round 2 题解
Codeforces Global Round 2 题目链接:https://codeforces.com/contest/1119 A. Ilya and a Colorful Walk 题意: 给 ...
- codeforces刷题记录
Codefest 19 (open for everyone, rated, Div. 1 + Div. 2) C. Magic Grid 这种题直接构造 数n是2的n次方的倍数的时候可以这样划分数 ...
- 【Codeforces】CF 911 D. Inversion Counting(逆序对+思维)
题目 传送门:QWQ 分析 思维要求比较高. 首先我们要把原图的逆序对q算出来. 这个树状数组或归并排序都ok(树状数组不用离散化好评) 那么翻转$[l,r]$中的数怎么做呢? 暴力过不了,我试过了. ...
随机推荐
- spring-boot-2.0.3源码篇 - @Configuration、Condition与@Conditional
前言 开心一刻 一名劫匪慌忙中窜上了一辆车的后座,上车后发现主驾和副驾的一男一女疑惑地回头看着他,他立即拔出枪威胁到:“赶快开车,甩掉后面的警车,否则老子一枪崩了你!”,于是副驾上的男人转过脸对那女的 ...
- 一个简易的Python爬虫,将爬取到的数据写入txt文档中
代码如下: import requests import re import os #url url = "http://wiki.akbfun48.com/index.php?title= ...
- day07 Class_field_method_反射
Class 由于Class类没有公共构造方法,所有创建Class的对象的方法有以下几种: 1).通过Class.forName()静态方法返回Class类的一个实例 Class cls=Class ...
- iOS---------获取当前年份
NSDate * senddate=[NSDate date]; NSDateFormatter *dateformatter=[[NSDateFormatter alloc] init]; [d ...
- 【English】十三、英语中的连词有哪些,都有什么作用
一.什么是连词 参考:https://m.hujiang.com/en_cixing/yylc/ 连词是一种虚词,用于连接单词.短语.从句或句子,在句子中不单独用作句子成分. 连词按其性质可分为并列连 ...
- [20190419]shared latch spin count.txt
[20190419]shared latch spin count.txt --//昨天测试exclusive latch spin count = 20000(缺省).--//今天测试shared ...
- Powershell-创建Module
1.找到默认module路径,ISE启动时自动加载默认领下的Module代码. $env:PSModulePath 2.在其中一个默认路径下创建个文件夹,在文件夹下创建一个.psm1后缀文件,注意文件 ...
- SQL Server中将多行数据拼接为一行数据(一个字符串)
表A中id与表B中aid为一对多的关系 例如: 表A: id name a1 tom a2 lily a3 lucy 表B: id aid value b1 a1 B1 b2 a1 B2 b3 a2 ...
- 练习 python之数据库增删改查
# 文件存储时可以这样表示 ## id,name,age,phone,dept,enroll_date# 1,Alex Li,22,13651054608,IT,2013-04-01# 2,Jack ...
- [已解决]报错:Required request body is missing
问题代码: res = requests.post(getXxxxList_url, headers=headers, data={}) 对象网站: angular4 apache 通过验证 (coo ...