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 ...
随机推荐
- vue-router的hash和history模式的区别
一.概念 为了构建 SPA(单页面应用),需要引入前端路由系统,这也就是 Vue-Router 存在的意义. 前端路由的核心,就在于:改变视图的同时不会向后端发出请求. 为了达到这种目的,浏览器当前提 ...
- css:鼠标点击出现有颜色的边框?如何解决
今天遇到上图这样出现有颜色的边框 解决办法: css设置属性 outline:none;
- alert(1) to win 8
function escape(s) { return '<script>console.log("' + s.toUpperCase() + '")</scri ...
- CentOS安装Git服务器 Centos 6.5 + Git 1.7.1.0 + gitosis
1.安装扩展 yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel 2.下载git ...
- Xcode出现报错,但是没有给出详细信息,可以看这里
Xcode出现报错,"Xcode build:clang: error: linker command failed with exit code 1 (use -v to..." ...
- 网页用html还是php
首先,不管是html还是php,虽然这是两种不同的语言,但是都可以编写网页.不同的是,使用html编写网页是纯静态的网页,无法是运行在本地的,且无法和用户进行交互:而使用php编写的网页则是动态的,运 ...
- ubuntu 18.04下修改pip镜像源
在home/用户名/目录下创建.pip文件夹 然后cd .pip 创建pip.conf文件touch pip.conf 输入以下内容然后保存即可 [global] timeout = 6000 ind ...
- Period POJ - 1961
Period POJ - 1961 时限: 3000MS 内存: 30000KB 64位IO格式: %I64d & %I64u 提交 状态 已开启划词翻译 问题描述 For each ...
- python之-框架
MVC:Model-View-Controller,中文名“模型-视图-控制器” C——Python处理URL的函数:Controller,Controller负责业务逻辑,比如检查用户名是否存在,取 ...
- onLayout初始化裁剪信息
在EasyConstraintLayout中初始化LayoutParamsData的paths @Override protected void onLayout(boolean changed, i ...