【链接】 我是链接,点我呀:)
【题意】
【题解】
显然应该有 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;
}