题面

传送门

分析

这种题的重点是寻找不变量

我们发现如果改变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(思维)的更多相关文章

  1. Codeforces 424A (思维题)

    Squats Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Statu ...

  2. Codeforces 1060E(思维+贡献法)

    https://codeforces.com/contest/1060/problem/E 题意 给一颗树,在原始的图中假如两个点连向同一个点,这两个点之间就可以连一条边,定义两点之间的长度为两点之间 ...

  3. Queue CodeForces - 353D (思维dp)

    https://codeforces.com/problemset/problem/353/D 大意:给定字符串, 每一秒, 若F在M的右侧, 则交换M与F, 求多少秒后F全在M左侧 $dp[i]$为 ...

  4. codeforces 1244C (思维 or 扩展欧几里得)

    (点击此处查看原题) 题意分析 已知 n , p , w, d ,求x , y, z的值 ,他们的关系为: x + y + z = n x * w + y * d = p 思维法 当 y < w ...

  5. CodeForces - 417B (思维题)

    Crash Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status ...

  6. CodeForces - 417A(思维题)

    Elimination Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit  ...

  7. CodeForces 625A 思维

    题意是说一个人喝酒 有两种办法 买塑料瓶的 a块钱 喝了就没了 或者是买玻璃瓶的b块钱 喝完还能卖了瓶子c块钱 求最多能喝多少瓶 在开始判断一次 a与b-c的关系 即两种方式喝酒的成本 如果a< ...

  8. Vladik and Complicated Book CodeForces - 811B (思维实现)

    Vladik had started reading a complicated book about algorithms containing n pages. To improve unders ...

  9. The Contest CodeForces - 813A (思维)

    Pasha is participating in a contest on one well-known website. This time he wants to win the contest ...

随机推荐

  1. css炫酷动画收藏

    1.按钮.hover.input动画(cssfx) https://cssfx.dev/ 2.svg 矢量定制icon(ikonate) https://www.ikonate.com/#conten ...

  2. File基本操作

    File (1)File是文件和目录路径名的抽象表示.IO流操作中大部分都是对文件的操作,因此Java就提供了File类供我们来操作文件. (2)构造方法 根据一个路径得到一个File对象      ...

  3. java 判断点是否在一条线段上

    public static void main(String[] args) { Scanner scan = new Scanner(System.in); Point point1 = new P ...

  4. SpringBoot 利用freemaker生成静态页面

    1. <!-- freemarker模板 --> <dependency> <groupId>org.springframework.boot</groupI ...

  5. springboot--异步执行的方法及定时执行的方法

    让方法被调用后异步的执行 一般来说,要异步执行一个任务都是创建一个线程来专门干这个任务.在springboot中有 @Async 这个注解快速实现方法的异步执行.只需要两步:第一步: 在启动类上加上@ ...

  6. hashlib模块subprocess模块

    '''通过一种算法,将字符串得出一种编码内容相同则hash运算结果相同,内容稍微改变则hash值改变不可逆推相同算法,无论校验多长的数据,得到的hash值长度固定'''# import hashlib ...

  7. Spring学习总结(1)- IOC

    一.Spring框架概述 Spring是一个开源免费的框架,为了解决企业应用开发的复杂性而创建.Spring框架是一个轻量级的解决方案,可以一站式地构建企业级应用.Spring是模块化的,所以可以只使 ...

  8. 容易混淆的JavaScript基础知识之语法部分

    type 属性: 默认的 type 就是 javascript, 所以不必显式指定 type 为 javascript javascript 不强制在每个语句结尾加 “:” , javascript ...

  9. android开发里跳过的坑——GridView使用Glide加载图片不显示

    用grideview显示本地图片列表,用了Glide加载框架,具体调用如下: Glide.with(mContext).load(Uri.fromFile(file)).into(imageView) ...

  10. BUUCTF | [CISCN2019 华北赛区 Day1 Web2]ikun

    步骤: 找到lv6的购买出,修改折扣买lv6 :然后找到admin的登陆界面,JWT破解,登陆admin :点击一键成为大会员,利用python反序列化漏洞读取flag 解析: 这题师傅们的WP已经很 ...