EDU #48 D

题意:给定一个矩阵,已知每一行和每一列上数字的异或和,问矩阵上的数字是多少,不存在则输出NO。

思路:构造题,可以考虑只填最后一行,和最后一列,其中(n,m)要特判一下。其他格子给0即可。

   自己之前接触这类题目较少,感觉写这种题,自己的智商都提高了。

    

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <cstdlib>
#include <iterator>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <cctype>
using namespace std;
//#pragma comment(linker, "/STACK:102400000,102400000") //c++
#define lson (l , mid , rt << 1)
#define rson (mid + 1 , r , rt << 1 | 1)
#define debug(x) cerr << #x << " = " << x << "\n";
#define pb push_back
#define pq priority_queue typedef long long ll;
typedef unsigned long long ull; typedef pair<ll ,ll > pll;
typedef pair<int ,int > pii; //priority_queue<int> q;//这是一个大根堆q
//priority_queue<int,vector<int>,greater<int> >q;//这是一个小根堆q
#define fi first
#define se second
#define endl '\n' #define OKC ios::sync_with_stdio(false);cin.tie(0)
#define FT(A,B,C) for(int A=B;A <= C;++A) //用来压行
#define REP(i , j , k) for(int i = j ; i < k ; ++i)
//priority_queue<int ,vector<int>, greater<int> >que; const ll mos = 0x7FFFFFFF; //
const ll nmos = 0x80000000; //-2147483648
const int inf = 0x3f3f3f3f;
const ll inff = 0x3f3f3f3f3f3f3f3f; // template<typename T>
inline T read(T&x){
x=;int f=;char ch=getchar();
while (ch<''||ch>'') f|=(ch=='-'),ch=getchar();
while (ch>=''&&ch<='') x=x*+ch-'',ch=getchar();
return x=f?-x:x;
}
// #define _DEBUG; //*//
#ifdef _DEBUG
freopen("input", "r", stdin);
// freopen("output.txt", "w", stdout);
#endif
/*-----------------show time----------------*/
const int maxn = ;
ll a[maxn],b[maxn];
ll q[maxn],p[maxn];
int n,m;
ll ans[maxn][maxn];
int main(){
OKC;
cin>>n>>m;
ll s1=,s2 = ;
for(int i=; i<=n; i++)cin>>a[i], s1 ^=a[i];
for(int j=; j<=m; j++)cin>>b[j], s2 ^=b[j];
if(s1!=s2){
puts("NO");
return ;
}
ll ss =s1;
cout<<"YES"<<endl;
for(int i=; i<=n; i++)
{
for(int j=; j<=m; j++)
{
if(i<n&&j<m)cout<<"0 ";
else {
if(i==n&&j==m){
cout<<(ss ^ a[n] ^ b[m]) <<" ";
}
else if(i==n){
cout<<b[j]<<" ";
}
else if(j==m){
cout<<a[i]<<" ";
}
}
} cout<<endl;
} return ;
}

EDU#48D

Educational Codeforces Round 48 D Vasya And The Matrix的更多相关文章

  1. Educational Codeforces Round 48 (Rated for Div. 2) CD题解

    Educational Codeforces Round 48 (Rated for Div. 2) C. Vasya And The Mushrooms 题目链接:https://codeforce ...

  2. 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 ...

  3. D. Vasya And The Matrix(Educational Codeforces Round 48)

    D. Vasya And The Matrix time limit per test2 seconds memory limit per test256 megabytes inputstandar ...

  4. Educational Codeforces Round 48

    题目地址 Edu48 A.Death Note 翻译 你有一个无穷页的本子,每一页可以写\(m\)个名字, 你在第\(i\)天要写\(a_i\)个名字,如果这一页恰好写满了,你就会翻页, 问每天的翻页 ...

  5. 【Educational Codeforces Round 48 (Rated for Div. 2) C】 Vasya And The Mushrooms

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 显然在没有一直往右走然后走到头再往上走一格再往左走到头之前. 肯定是一直在蛇形走位.. 这个蛇形走位的答案贡献可以预处理出来.很容易 ...

  6. 【Educational Codeforces Round 48 (Rated for Div. 2) D】Vasya And The Matrix

    [链接] 我是链接,点我呀:) [题意] 告诉你每一行.每一列的异或和. 让你求出一个符合要求的原矩阵. [题解] 显然应该有 a1^a2^....^an = b1^b2^....^bn 也即两边同时 ...

  7. Educational Codeforces Round 48 (Rated for Div. 2)

    http://codeforces.com/contest/1016 A. 没想到这个也会TLE,太粗心了 B. 暴力就好了,多情况讨论又出错... 思路跟我一样的解法   为什么我做了那么多讨论,原 ...

  8. Educational Codeforces Round 54 E. Vasya and a Tree(树上差分数组)

    https://codeforces.com/contest/1076/problem/E 题意 给一棵树(n<=3e5),m(3e5)次查询,每次查询u,d,x,表示在u的子树中,给距离u&l ...

  9. 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 ...

随机推荐

  1. 【Python3爬虫】当爬虫碰到表单提交,有点意思

    一.写在前面 我写爬虫已经写了一段时间了,对于那些使用GET请求或者POST请求的网页,爬取的时候都还算得心应手.不过最近遇到了一个有趣的网站,虽然爬取的难度不大,不过因为表单提交的存在,所以一开始还 ...

  2. 【Java】Class JavaLaunchHelper is implemented in both ** and **

    详细问题描述如下: objc[64179]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachin ...

  3. Java连载10-数据类型取值范围&转义字符

    一.数据类型取值范围 二.八种数据类型在成员变量中的默认值 (1)成员变量,没有赋值,编译不会报错,系统会自动给赋值 byte\int\short\long默认值为0:float\double默认值为 ...

  4. 第三章、Go-内建容器

    3.1.数组 (1)数组的定义 package main import ( "fmt" ) func main() { //用var定义数组可以不用赋初值 var arr1 [5] ...

  5. Android--SharedPreferences数据存储方案

            SharedPreferences是使用键值对的形式存储的,并且支持多种不同的数据类型,存的是String,取得值也是String.         使用SharedPreferenc ...

  6. opencv图像直方图均衡化及其原理

    直方图均衡化是什么有什么用 先说什么是直方图均衡化,通俗的说,以灰度图为例,原图的某一个像素为x,经过某个函数变为y.形成新的图.新的图的灰度值的分布是均匀的,这个过程就叫直方图均衡化. 图像直方图均 ...

  7. HTML/CSS:div水平与元素垂直居中(2)

    单个div水平居中:设置margin的左右边距为自动 div水平和垂直居中,text-align和vertical-align不起作用,因为标签div没有这两个属性,所以再css中设置这两个值不能居中 ...

  8. WebService1

    一.什么是WebService(来源百度百科) Web service是一个平台独立的,低耦合的,自包含的.基于可编程的web的应用程序,可使用开放的XML(标准通用标记语言下的一个子集)标准来描述. ...

  9. 爬虫之爬取电影天堂(request)

    #需要通过代码打开https://www.dytt8.net/网站,拿到网站内容 from urllib.request import urlopen #拿到urlopen import re con ...

  10. Android8.1 MTK平台 截屏功能分析

    前言 涉及到的源码有 frameworks\base\services\core\java\com\android\server\policy\PhoneWindowManager.java vend ...