Codeforces 1119C(思维)
题面
分析
这种题的重点是寻找不变量
我们发现如果改变4个角,则每一行和每一列的xor和不会改变(10=01)
所以只要算出异或和然后比较就可以
代码
#include<iostream>
#include<cstdio>
#define maxn 505
using namespace std;
int n,m;
int a[maxn][maxn];
int b[maxn][maxn];
int ar[maxn],ac[maxn];
int br[maxn],bc[maxn];
void work(int cmd,int *row,int *col){
if(cmd==0){
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
row[i]=row[i]^a[i][j];
col[j]=col[j]^a[i][j];
}
}
}else{
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
row[i]=row[i]^b[i][j];
col[j]=col[j]^b[i][j];
}
}
}
}
int main(){
scanf("%d %d",&n,&m);
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
scanf("%d",&a[i][j]);
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
scanf("%d",&b[i][j]);
}
}
work(0,ar,ac);
work(1,br,bc);
for(int i=1;i<=n;i++){
if(ar[i]!=br[i]){
printf("No\n");
return 0;
}
}
for(int i=1;i<=m;i++){
if(ac[i]!=bc[i]){
printf("No\n");
return 0;
}
}
printf("Yes\n");
}
Codeforces 1119C(思维)的更多相关文章
- Codeforces 424A (思维题)
Squats Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submit Statu ...
- Codeforces 1060E(思维+贡献法)
https://codeforces.com/contest/1060/problem/E 题意 给一颗树,在原始的图中假如两个点连向同一个点,这两个点之间就可以连一条边,定义两点之间的长度为两点之间 ...
- Queue CodeForces - 353D (思维dp)
https://codeforces.com/problemset/problem/353/D 大意:给定字符串, 每一秒, 若F在M的右侧, 则交换M与F, 求多少秒后F全在M左侧 $dp[i]$为 ...
- codeforces 1244C (思维 or 扩展欧几里得)
(点击此处查看原题) 题意分析 已知 n , p , w, d ,求x , y, z的值 ,他们的关系为: x + y + z = n x * w + y * d = p 思维法 当 y < w ...
- CodeForces - 417B (思维题)
Crash Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submit Status ...
- CodeForces - 417A(思维题)
Elimination Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submit ...
- CodeForces 625A 思维
题意是说一个人喝酒 有两种办法 买塑料瓶的 a块钱 喝了就没了 或者是买玻璃瓶的b块钱 喝完还能卖了瓶子c块钱 求最多能喝多少瓶 在开始判断一次 a与b-c的关系 即两种方式喝酒的成本 如果a< ...
- Vladik and Complicated Book CodeForces - 811B (思维实现)
Vladik had started reading a complicated book about algorithms containing n pages. To improve unders ...
- The Contest CodeForces - 813A (思维)
Pasha is participating in a contest on one well-known website. This time he wants to win the contest ...
随机推荐
- Multisim
万用表 测量电压.电流.电阻 直流.交流 函数发生器XFG 正极.负极.公共端 可以产生正弦波.三角波和矩形波,可以设置信号参数:频率.占空比.幅度和偏移量等 示波器XSC 双通道示波器 4个连接点, ...
- bzoj3589 动态树 树链剖分+容斥
题目传送门 https://lydsy.com/JudgeOnline/problem.php?id=3589 题解 事件 \(0\) 不需要说,直接做就可以了. 事件 \(1\) 的话,考虑如果直接 ...
- css 表单头部固定
原创 https://blog.csdn.net/q3585914/article/details/69946478 table表头和首列的表格固定-CSS实现的Table表头固定 原创 2017年0 ...
- 02.list--约瑟夫环
from fib import fib # 参考01.线性表 def josephus_a(n, k, m): """ 约瑟夫环 没有人用0表示,n个人出列即结束 :pa ...
- R语言里面的循环变量
for (i in 1:10) { print("Hello world") } 以上这条命令执行完之后,变量i会被保存下来!并且,i的值将是10. 程序中有多处循环的时候要非常注 ...
- 【java】Split函数踩坑记
先看一段代码: String line = "openssh|7.1"; String[] pkg = line.split("|"); System.out. ...
- Task2.特征提取
参考:https://blog.csdn.net/u012052268/article/details/77825981/ 利用jieba分词工具去除停用词: 停用词:1.在SEO中为节省空间和提高搜 ...
- Android之SAX解析笔记
books.xml: <?xml version="1.0" encoding="utf-8"?> <books> <book i ...
- windows系统如何查看物理cpu核数,内存型号等
首先,我们需要打开命令行模式,利用win+r键打开运行,输入cmd回车即会出现 然后在命令行界面输入wmic进入命令行系统管理执行脚本界面 然后我们通过cpu get *可以查看cpu的具 ...
- Python3解leetcode First Bad Version
问题描述: You are a product manager and currently leading a team to develop a new product. Unfortunately ...