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

【题意】

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

【题解】

显然应该有
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. #leetcode#Anagrames

    Given an array of strings, return all groups of strings that are anagrams. Note: All inputs will be ...

  2. Bootstrap的js插件之警告框(alert.js)

    data-dismiss="alert"--为关闭button加入该属性能够使其自己主动为警告框赋予关闭功能. .fade .in--为警告框在关闭时加入动画效果. 很多其它细节參 ...

  3. Project Euler:Problem 77 Prime summations

    It is possible to write ten as the sum of primes in exactly five different ways: 7 + 3 5 + 5 5 + 3 + ...

  4. 计算工作日之后N天的日期

    1.假期实体类: package com.smics.date; import java.io.Serializable; import java.util.Date; public class Va ...

  5. 深度学习实战篇-基于RNN的中文分词探索

    深度学习实战篇-基于RNN的中文分词探索 近年来,深度学习在人工智能的多个领域取得了显著成绩.微软使用的152层深度神经网络在ImageNet的比赛上斩获多项第一,同时在图像识别中超过了人类的识别水平 ...

  6. java8新特性系列:[1]让你的eclipse支持java8

    package com.anhui.jdk8; /** * 针对eclipse是否支持java8小测试 * MainClass * @author zhongzh * */ public class ...

  7. Elasticsearch日志收集

    Install pip if necessary curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py&q ...

  8. BZOJ 2929 网络流

    题意是啥--. 思路: 不是与1或n连起来的边 边权是1 否则是inf 跑网络流 //By SiriusRen #include <queue> #include <cstdio&g ...

  9. A - Presents

    Problem description Little Petya very much likes gifts. Recently he has received a new laptop as a N ...

  10. 兼容各个浏览器的jquyer zclip复制文本插件 无效的解决办法

    项目中使用点击文本复制功能,用了这个兼容各个浏览器的插件,但是发现放在最前面正常,放到嵌套的html中就失效. 解决办法: <span style="position: relativ ...