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 ...
随机推荐
- map集合中取出分类优先级最高的类别名称
import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.Map ...
- 18-基于双TMS320C6678 DSP的3U VPX的信号处理平台
基于双TMS320C6678 DSP的3U VPX的信号处理平台 一.板卡概述 板卡由我公司自主研发,基于3U VPX架构,处理板包含两片TI DSP TMS320C6678芯片:一片Xilinx公司 ...
- Intel MKL函数之 cblas_sgemm、cblas_sgemm_batch
cblas_sgemm int m = 40; int k = 20; int n = 40; std::vector<float> a(m*k, 1.0); std::vector< ...
- Axios跨域实例
//创建axios实例 var instance = axios.create({ baseURL : "http://localhost:8080", withCredentia ...
- image按钮新增的width属性和height属性
代码实例: test.html <!DOCTYPE html> <html lang="en"> <head> <meta charset ...
- BitMap位图
BitMap位图算法https://blog.csdn.net/varyall/article/details/79662029 常见面试题 题1:在2.5亿个整数找出不重复的整数,内存不足以容纳着2 ...
- Flutter-charts_flutter圖表
pub.dev搜索charts_flutter 導入依賴 charts_flutter: ^0.8.1 項目導入 import 'package:charts_flutter/flutter.dart ...
- A1001
两数相加,结果每三位添加一个逗号.一开始没有注意到%03d的问题,因为有某些数据逗号分割后高位带0,因此需要用0来补充空位. #include<iostream> #include< ...
- 4412 移植x264并且YUV422转x264
转自http://blog.sina.com.cn/s/blog_af9acfc60101alxx.html 一.YUV422转换规律 做视频采集与处理,自然少不了要学会分析YUV数据.因为从采集的角 ...
- JavaScript 常用的技术(陆续更新)
截取字符串(指定长度) var str = "abc-110001"; //str.substring(起始位置(0开始),截取的长度) str.substring(0,4); / ...