Codeforces Round #553 (Div. 2) B题
题目网址:http://codeforces.com/contest/1151/problem/B
题目大意:给定一个n*m的矩阵,问是否可以从每一行中选择一个数,使得这n个数异或大于0,如果可以还要输出它们的列位置
题解:首先如果a^b==0,b!=c,则a^c>0.那么考虑构造,为了方便,选取第一列的数,如果异或>0,直接输出列位置,反之则随便在一行中,找到一个与第一个不相等的数,那么由异或性质满足条件,如果n行都找不到,则无法实现。
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=5e2+;
int a[maxn][maxn];
int main()
{
int n,m;
std::ios::sync_with_stdio(false);
cin>>n>>m;
for(int i=;i<=n;i++) for(int j=;j<=m;j++) cin>>a[i][j];
int ans=a[][];
for(int i=;i<=n;i++) ans^=a[i][];
if(ans) {
cout<<"TAK"<<endl;
for(int i=;i<=n;i++) printf("1 ");puts(" ");
return ;
}
int flag=,x,y;
for(int i=;i<=n;i++) {
for(int j=;j<=m;j++) {
if(a[i][]!=a[i][j]) {
x=i,y=j;flag=;
}
}
}
if(flag) {
cout<<"TAK"<<endl;
for(int i=;i<=x-;i++) printf("1 ");
printf("%d ",y);
for(int i=x+;i<=n;i++) printf("1 ");puts(" ");
return ;
} cout<<"NIE"<<endl;
}
Codeforces Round #553 (Div. 2) B题的更多相关文章
- Codeforces Round #553 (Div. 2) D题
题目网址:http://codeforces.com/contest/1151/problem/D 题目大意:给出n组数对,(ai , bi),调整这n组数对的位置,最小化 ∑(ai*( i -1)+ ...
- Codeforces Round #553 (Div. 2) C题
题目网址:http://codeforces.com/contest/1151/problem/C 题目大意:给定奇数集和偶数集,现构造一个数组,先取奇数集中一个元素1,再取偶数集二个元素2,4,再取 ...
- Codeforces Round #553 (Div. 2) A题
题目网址:http://codeforces.com/contest/1151/problem/A 题目大意:给定一个由大写字母构成的字符串和它的长度,有这样的操作,使任意一个字母变成与其相邻的字母, ...
- Codeforces Round #378 (Div. 2) D题(data structure)解题报告
题目地址 先简单的总结一下这次CF,前两道题非常的水,可是第一题又是因为自己想的不够周到而被Hack了一次(或许也应该感谢这个hack我的人,使我没有最后在赛后测试中WA).做到C题时看到题目情况非常 ...
- Codeforces Round #612 (Div. 2) 前四题题解
这场比赛的出题人挺有意思,全部magic成了青色. 还有题目中的图片特别有趣. 晚上没打,开virtual contest打的,就会前三道,我太菜了. 最后看着题解补了第四道. 比赛传送门 A. An ...
- Codeforces Round #713 (Div. 3)AB题
Codeforces Round #713 (Div. 3) Editorial 记录一下自己写的前二题本人比较菜 A. Spy Detected! You are given an array a ...
- Codeforces Round #552 (Div. 3) A题
题目网址:http://codeforces.com/contest/1154/problem/ 题目意思:就是给你四个数,这四个数是a+b,a+c,b+c,a+b+c,次序未知要反求出a,b,c,d ...
- Codeforces Round #412 Div. 2 补题 D. Dynamic Problem Scoring
D. Dynamic Problem Scoring time limit per test 2 seconds memory limit per test 256 megabytes input s ...
- Codeforces Round #271 (Div. 2) E题 Pillars(线段树维护DP)
题目地址:http://codeforces.com/contest/474/problem/E 第一次遇到这样的用线段树来维护DP的题目.ASC中也遇到过,当时也非常自然的想到了线段树维护DP,可是 ...
随机推荐
- 在linux上构建gitolite
每台机器生成密钥前要设置邮箱和用户名: git config --global user.name "admin" git config --global user.email & ...
- About Gnu Linker2
3.5.1 Simple Assignments symbol = expression ; symbol += expression ; The first case will define sym ...
- Creating and using a blendspace in c++
转自:https://forums.unrealengine.com/development-discussion/c-gameplay-programming/104831-creating-and ...
- spark2.1源码分析1:Win10下IDEA源码阅读环境的搭建
环境:win10.IDEA2016.3.maven3.3.9.git.scala 2.11.8.java1.8.0_101.sbt0.13.12 下载: #git bash中执行: git clone ...
- 数据库新增“自动添加”类字段 auto_now_add 如何不影响之前数据
django 中的模版为例:time = models.DateTimeField('创建时间', auto_now_add=True)这样显然是不行的.那么.我们可以考虑先给前面数据一个默认值迁移一 ...
- intellij与eclipse默认快捷键对比
最近想用intellij,于是找找快捷键.用惯了eclipse,都不太适应intellij的快捷键.慢慢的就适应了常用的快捷键 Idea 与 Eclipse 快捷键的区别,上为Eclipse的快捷键, ...
- Vsftpd服务重启、暂停命令
VSFTP是一个基于GPL发布的类Unix系统上使用的FTP服务器软件,它的全称是Very Secure FTP 从此名称可以看出来,编制者的初衷是代码的安全. 在使用Vsftp服务是经常需要启动.停 ...
- node图片资源捉取
开头先简单说明一下,因为网络资源上最多的资源就是图片,所以在这里也只简单的捉取了图片资源,至于其他的文档,音乐等我是没有试过的.所以暂时还是以图片为案例!!! Step1 首先我们需要加载我们需要的资 ...
- Caused by: java.lang.IllegalArgumentException: argument type mismatch
下面是我的报错信息 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java: ...
- User authentication in Django(用户认证)
一,概述: auth 系统包括: 1)Users 2)Permissions: Binary (yes/no) flags designating whether a user may perform ...