【链接】 我是链接,点我呀:)

【题意】

告诉你每一行、每一列的异或和。
让你求出一个符合要求的原矩阵。

【题解】

显然应该有
a1^a2^....^an = b1^b2^....^bn
也即两边同时异或一下a1^b1
b1^a2^a3...^an =a1^b2^...^bn
我们设x=b1^a2^a3...^an =a1^b2^...^bn
然后我们就能得到一个符合要求的矩阵了
![](https://images2018.cnblogs.com/blog/1251265/201808/1251265-20180804114209048-744453766.png)
会发现第一列的异或和就是b1.第一行的异或和就是a1
因为x同时可以写成上面的那两种形式
第2到第n行以及第2到第m列显然也是满足要求的,下面全是0了

【代码】

#include <bits/stdc++.h>
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define lson l,mid,rt<<1
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%lld",&x)
#define res(x) scanf("%s",x)
#define rson mid+1,r,rt<<1|1
using namespace std; const double pi = acos(-1);
const int dx[4] = {0,0,1,-1};
const int dy[4] = {1,-1,0,0}; const int N =1000000; LL m,n,arr[N+10],brr[N+10],ans[1000][1000]; int main()
{
#ifdef LOCAL_DEFINE
freopen("rush_in.txt", "r", stdin);
#endif
ios::sync_with_stdio(0),cin.tie(0);
cin >> n>> m;
int a=0,b=0;
for (int i = 0; i < n; i++)
{
cin >>arr[i];
if(i!=0) a=a^arr[i];
}
for (int i = 0; i < m; i++)
{
cin >>brr[i];
if(i!=0) b=b^brr[i];
}
a=a^brr[0];
b=b^arr[0];
if(a!=b){
cout << "NO" <<endl;
return 0;
}
rep1(i,0,n-1){
rep1(j,0,m-1){
if(i==0&&j==0) ans[i][j]=a;
else if(i==0)
{
ans[i][j]=brr[j];
}
else if(j==0)
{
ans[i][j]=arr[i];
}
}
}
cout << "YES" <<endl;
rep1(i,0,n-1){
rep1(j,0,m-1){
if(j!=0) cout << " ";
cout <<ans[i][j] ;
}
cout << endl;
}
return 0;
}

【Educational Codeforces Round 48 (Rated for Div. 2) D】Vasya And The Matrix的更多相关文章

  1. 【Educational Codeforces Round 48 (Rated for Div. 2) C】 Vasya And The Mushrooms

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 显然在没有一直往右走然后走到头再往上走一格再往左走到头之前. 肯定是一直在蛇形走位.. 这个蛇形走位的答案贡献可以预处理出来.很容易 ...

  2. 【Educational Codeforces Round 53 (Rated for Div. 2) C】Vasya and Robot

    [链接] 我是链接,点我呀:) [题意] [题解] 如果|x|+|y|>n 显然.从(0,0)根本就没法到(x,y) 但|x|+|y|<=n还不一定就能到达(x,y) 注意到,你每走一步路 ...

  3. Educational Codeforces Round 48 (Rated for Div. 2) D 1016D Vasya And The Matrix (构造)

    D. Vasya And The Matrix time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  4. 【 Educational Codeforces Round 51 (Rated for Div. 2) F】The Shortest Statement

    [链接] 我是链接,点我呀:) [题意] [题解] 先处理出来任意一棵树. 然后把不是树上的边处理出来 对于每一条非树边的点(最多21*2个点) 在原图上,做dijkstra 这样就能处理出来这些非树 ...

  5. 【Educational Codeforces Round 41 (Rated for Div. 2) D】Pair Of Lines

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 如果点的个数<=3 那么直接输出有解. 否则. 假设1,2最后会在一条直线上,则把这条直线上的点都删掉. 看看剩余的点是否在同 ...

  6. Educational Codeforces Round 48 (Rated for Div. 2) CD题解

    Educational Codeforces Round 48 (Rated for Div. 2) C. Vasya And The Mushrooms 题目链接:https://codeforce ...

  7. Educational Codeforces Round 48 (Rated for Div. 2)

    http://codeforces.com/contest/1016 A. 没想到这个也会TLE,太粗心了 B. 暴力就好了,多情况讨论又出错... 思路跟我一样的解法   为什么我做了那么多讨论,原 ...

  8. Educational Codeforces Round 48 (Rated for Div. 2) B 1016B Segment Occurrences (前缀和)

    B. Segment Occurrences time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  9. 【Educational Codeforces Round 38 (Rated for Div. 2)】 Problem A-D 题解

    [比赛链接] 点击打开链接 [题解] Problem A Word Correction[字符串] 不用多说了吧,字符串的基本操作 Problem B  Run for your prize[贪心] ...

随机推荐

  1. HDU2191_悼念512汶川大地震遇难同胞——珍惜如今,感恩生活(背包/多重背包)

    解题报告 题目传送门 题意: 中文不多说; 思路: 基础多重背包,每一个物品有多个能够选.转换成01背包解. #include <iostream> #include <cstrin ...

  2. fputs与fgets

    1.      fputs 函数名: fputs  功  能: 送一个字符到一个流中  用  法: int fputs(char *string, FILE *stream); 说明: fputs是一 ...

  3. 【cl】子查询应用场景

    有推荐人/没有推荐人的 recommender_id is null / is not null 谁是推荐人=他的id是别人的recommender_id=某个人的recommender_id是他的i ...

  4. sql处理高并发

    sql处理高并发,防止库存超卖 2014-08-14 23:44 13560人阅读 评论(2) 收藏 举报  分类: 数据库(43)  今天王总又给我们上了一课,其实mysql处理高并发,防止库存超卖 ...

  5. 怎样使用Eclipse PDT调试PHP程序

    本文主要介绍的是怎样用eclipse pdt调试PHP 代码. 1. 下载eclipse.从官网上找就能够了,并确认当前系统中有java环境,即jdk和jre. 2. 安装pdt了,採用的是在线安装. ...

  6. MySQL数据库——存储和函数

    一.存储过程1 基本语法CREATE PROCEDURE sp_name ([proc_parameter[,...]]) [characteristic ...] routine_body 格式[I ...

  7. 自定义控件三部曲之动画篇(四)——ValueAnimator基本使用

    前言:不要让别人的无知断送了你的梦想,永远坚信你所坚信的. 相关文章: <Android自定义控件三部曲文章索引>:http://blog.csdn.net/harvic880925/ar ...

  8. linux下图片转换工具[【转】

    本文转载自:https://linux.cn/article-8014-1.html 计算机术语中,批处理指的是用一个非交互式的程序来执行一序列的任务的方法.这篇教程里,我们会使用 Linux 命令行 ...

  9. poj--2553--The Bottom of a Graph (scc+缩点)

    The Bottom of a Graph Time Limit : 6000/3000ms (Java/Other)   Memory Limit : 131072/65536K (Java/Oth ...

  10. RAR 5.50 控制台使用记录

    copy from  WinRAR用户手册,备忘 用户手册 ~~~~~~~~ RAR 5.50 控制台版本 ~~~~~~~~~~~~~~~~~~~ =-=-=-=-=-=-=-=-=-=-=-=-=- ...