【Educational Codeforces Round 48 (Rated for Div. 2) D】Vasya And The Matrix
for The and Codeforces div round matrix 48
2023-09-14 09:03:44 时间
【链接】 我是链接,点我呀:)
【题意】
【题解】
显然应该有 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;
}
相关文章
- org.hibernate.HibernateException: No Session found for current thread
- 【Linux异常】执行man proc查看proc文档时提示错误 man: can't set the locale; make sure $LC_* and $LANG are correct No manual entry for proc
- jdk8新特性:在用Repository实体查询是总是提示要java.util.Optional, 原 Inferred type 'S' for type parameter 'S' is not within its bound;
- Error: 9001, Severity: 21, State: 5 The log for database 'xxxx' is not available
- [Web] Possible bug for Cache the network request
- [HTML 5] Transforming FormData for the Server (URLSearchParams)
- [Functional Programming] foldMap for Monoids
- [HTML5] Native lazy-loading for the web
- [Angular] Architectures for Huge Angular Based Enterprise
- [CSS] Showing horizontal scrollbar always for the table
- [Node.js]31. Level 7: Redis coming for Node.js, Simple Redis Commands
- HADOOP:WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable终于解决了
- [Kotlin] for loop
- [React] Use React.ReactNode for the children prop in React TypeScript components and Render Props
- 解决go项目报错:fatal: could not read Username for ‘https://gitee.com‘: terminal prompts disabled
- Jenkins 构建报错:Couldn‘t find any revision to build. Verify the repository and branch configuration for
- SAP CRM错误消息 Specify at least one number for the business partner
- SAP CRM和Cloud for Customer的Account merge
- How to find the service contract list for a given individual object
- Data for set COM_LOCAT_ADDR may only be changed in the original system CRQ_100
- 使用 cf push 部署应用到 SAP BTP 时遇到错误消息 No domains exist for route
- GcExcel 4.0.2 for Java and C# The Crack
- 成功解决TypeError: ufunc 'sqrt' not supported for the input types, and the inputs could not be safely co
- 第十四届蓝桥杯集训——for——判断质数/素数
- 已解决One or more issues caused the setup to fail.Please fix the issues and then retry setup.For more i
- 云图说|初识云数据库GaussDB(for Redis)
- 使用generate...for语句简化代码
- Error:Could not determine the class-path for interface com.android.builder.model.AndroidProject
- 解决No registered ‘MultiDeviceIteratorGetNextFromShard‘ OpKernel for GPU devices compatible with node
- Choose the best AI service for your needs
- 【异常】IDEA报错There is insufficient memory for the Java Runtime Environment to continue.