cf 1016D
2 seconds
256 megabytes
standard input
standard output
Now Vasya is taking an exam in mathematics. In order to get a good mark, Vasya needs to guess the matrix that the teacher has constructed!
Vasya knows that the matrix consists of n rows and m columns. For each row, he knows the xor (bitwise excluding or) of the elements in this row. The sequence a1, a2, ..., an denotes the xor of elements in rows with indices 1, 2, ..., n, respectively. Similarly, for each column, he knows the xor of the elements in this column. The sequence b1, b2, ..., bm denotes the xor of elements in columns with indices 1, 2, ..., m, respectively.
Help Vasya! Find a matrix satisfying the given constraints or tell him that there is no suitable matrix.
The first line contains two numbers n and m (2 ≤ n, m ≤ 100) — the dimensions of the matrix.
The second line contains n numbers a1, a2, ..., an (0 ≤ ai ≤ 109), where ai is the xor of all elements in row i.
The third line contains m numbers b1, b2, ..., bm (0 ≤ bi ≤ 109), where bi is the xor of all elements in column i.
If there is no matrix satisfying the given constraints in the first line, output "NO".
Otherwise, on the first line output "YES", and then n rows of m numbers in each ci1, ci2, ... , cim (0 ≤ cij ≤ 2·109) — the description of the matrix.
If there are several suitable matrices, it is allowed to print any of them.
2 3
2 9
5 3 13
YES
3 4 5
6 7 8
3 3
1 7 6
2 15 12
NO
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <string>
#include <deque>
using namespace std;
#define ll long long
#define N 109
#define gep(i,a,b) for(int i=a;i<=b;i++)
#define gepp(i,a,b) for(int i=a;i>=b;i--)
#define gep1(i,a,b) for(ll i=a;i<=b;i++)
#define gepp1(i,a,b) for(ll i=a;i>=b;i--)
#define mem(a,b) memset(a,b,sizeof(a))
int n,m;
int a[N],b[N],c[N][N];
int main()
{
scanf("%d%d",&n,&m);
int x=,y=;
gep(i,,n) {
scanf("%d",&a[i]);
x^=a[i];
}
gep(j,,m){
scanf("%d",&b[j]);
y^=b[j];
}
if(x!=y){
printf("NO\n");
return ;
}
x^=a[];x^=b[];
c[][]=x;
gep(i,,n){
c[i][]=a[i];
}
gep(j,,m){
c[][j]=b[j];
}
printf("YES\n");
gep(i,,n){
gep(j,,m){
printf("%d%c",c[i][j],j==m?'\n':' ');
}
}
return ;
}
cf 1016D的更多相关文章
- ORA-00494: enqueue [CF] held for too long (more than 900 seconds) by 'inst 1, osid 5166'
		凌晨收到同事电话,反馈应用程序访问Oracle数据库时报错,当时现场现象确认: 1. 应用程序访问不了数据库,使用SQL Developer测试发现访问不了数据库.报ORA-12570 TNS:pac ... 
- cf之路,1,Codeforces Round #345 (Div. 2)
		cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ... 
- cf Round 613
		A.Peter and Snow Blower(计算几何) 给定一个点和一个多边形,求出这个多边形绕这个点旋转一圈后形成的面积.保证这个点不在多边形内. 画个图能明白 这个图形是一个圆环,那么就是这个 ... 
- ARC下OC对象和CF对象之间的桥接(bridge)
		在开发iOS应用程序时我们有时会用到Core Foundation对象简称CF,例如Core Graphics.Core Text,并且我们可能需要将CF对象和OC对象进行互相转化,我们知道,ARC环 ... 
- [Recommendation System] 推荐系统之协同过滤(CF)算法详解和实现
		1 集体智慧和协同过滤 1.1 什么是集体智慧(社会计算)? 集体智慧 (Collective Intelligence) 并不是 Web2.0 时代特有的,只是在 Web2.0 时代,大家在 Web ... 
- CF memsql Start[c]UP 2.0 A
		CF memsql Start[c]UP 2.0 A A. Golden System time limit per test 1 second memory limit per test 256 m ... 
- CF memsql Start[c]UP 2.0 B
		CF memsql Start[c]UP 2.0 B B. Distributed Join time limit per test 1 second memory limit per test 25 ... 
- CF #376 (Div. 2)    C.  dfs
		1.CF #376 (Div. 2) C. Socks dfs 2.题意:给袜子上色,使n天左右脚袜子都同样颜色. 3.总结:一开始用链表存图,一直TLE test 6 (1)如果需 ... 
- CF #375 (Div. 2)   D.      bfs
		1.CF #375 (Div. 2) D. Lakes in Berland 2.总结:麻烦的bfs,但其实很水.. 3.题意:n*m的陆地与水泽,水泽在边界表示连通海洋.最后要剩k个湖,总要填掉多 ... 
随机推荐
- 如何使用程序调用webApi接口
			如何使用程序调用webApi接口 在C#中,传统调用HTTP接口一般有两种办法: WebRequest/WebResponse组合的方法调用 WebClient类进行调用. 第一种方法抽象程度较低,使 ... 
- Github开源项目单
			以下涉及到的数据统计与 2019 年 5 月 1 日 12 点,数据来源:https://github.com/trending/java?since=monthly . 下面的内容从 Java 学习 ... 
- JVM-GC日志分析
			程序运行时配置如下参数: -Xms20M -Xmx20M -Xmn10M -verbose:gc -XX:+PrintGCDetails -XX:SurvivorRatio= -XX:+PrintGC ... 
- 前端之CSS字体和文本类属性
			一.字体类属性: 1.字体类型: font-family:字体1,字体2,字体3; 常用写法: font-family:"微软雅黑",Arial; 注:a) 多个字体之间用逗号分隔 ... 
- 洛谷P4017 最大食物链计数
			拓扑排序板子题 #include <iostream> #include <cstdio> #include <cstring> #include <queu ... 
- JavaScript中,关于class的调用
			PS:class的调用,其实是可以叠加的,当然了这要求样式不同的情况下,如果样式相同,则后一个样式会覆盖前一个样式. 1.举例如下: <div id="test" class ... 
- selenium-Python之鼠标事件
			通过click()来模拟鼠标的单击操作,鼠标还具有鼠标右击,双击,悬停甚至鼠标拖动等功能.在webdriver中,将这些鼠标操作方法封装在ActionChains类提供. ActionChains类提 ... 
- 包含日志文件getshell
			包含日志文件getshell 一.包含日志文件漏洞利用概述 当我们没有上传点,并且也没有url_allow_include功能时,我们就可以考虑包含服务器的日志文件. ... 
- 状态压缩---区间dp第一题
			标签: ACM 题目 Gappu has a very busy weekend ahead of him. Because, next weekend is Halloween, and he is ... 
- Could not load OpenSSL解决
			问题 Could not load OpenSSL. You must recompile Ruby with OpenSSL support or change the sources in you ... 
