cf 1016D

D. Vasya And The Matrix
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
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.

Input

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.

Output

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.

Examples
input
Copy
2 3
2 9
5 3 13
output
Copy
YES
3 4 5
6 7 8
input
Copy
3 3
1 7 6
2 15 12
output
Copy
NO




复制代码
 1 #include <iostream>
 2 #include <cstdio>
 3 #include <algorithm>
 4 #include <cstdlib>
 5 #include <cstring>
 6 #include <string>
 7 #include <deque>
 8 using namespace std;
 9 #define ll long long 
10 #define  N 109
11 #define  gep(i,a,b)     for(int  i=a;i<=b;i++)
12 #define  gepp(i,a,b)   for(int  i=a;i>=b;i--)
13 #define  gep1(i,a,b)   for(ll i=a;i<=b;i++)
14 #define  gepp1(i,a,b)  for(ll i=a;i>=b;i--)    
15 #define  mem(a,b)  memset(a,b,sizeof(a))
16 int n,m;
17 int a[N],b[N],c[N][N];
18 int main()
19 {
20     scanf("%d%d",&n,&m);
21     int  x=0,y=0;
22     gep(i,1,n) {
23     scanf("%d",&a[i]);
24     x^=a[i];
25     } 
26     gep(j,1,m){
27         scanf("%d",&b[j]);
28         y^=b[j];
29     }
30     if(x!=y){
31         printf("NO\n");
32         return 0;
33     }
34     x^=a[1];x^=b[1];
35     c[1][1]=x;
36     gep(i,2,n){
37         c[i][1]=a[i];
38     }
39     gep(j,2,m){
40         c[1][j]=b[j];
41     }
42     printf("YES\n");
43     gep(i,1,n){
44         gep(j,1,m){
45             printf("%d%c",c[i][j],j==m?'\n':' ');
46         }
47     }
48     return 0;
49 }
复制代码

 

posted on   cltt  阅读(166)  评论(0编辑  收藏  举报

编辑推荐:
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示