题意:

给出一个矩阵n(<=500)*m(<=500)每一行任选一个数 异或在一起 求一个 异或在一起不为0 的每行的取值列号

思路: 异或的性质  交换律 x1^x2^x3==x3^x2^x1 可以任意换位置  并且 x1^x2==x3^x4  等于 x1^x2^x3==x4 可以任意换位置

所以等于零时有  x1^x2^x3^x4==0  (x1^x2)^(x3^x4)==0  x1^x2==x3^x4 都可以任意结合

所以本题只要任意选择列  如果为0  就每一列 找与已选择的列不一样的即可 如果找不到就输出-1

 #include<bits/stdc++.h>
#define FOR(i,f_start,f_end) for(int i=f_start;i<=f_end;i++)
#define MS(arr,arr_value) memset(arr,arr_value,sizeof(arr))
#define F first
#define S second
#define pii pair<int ,int >
#define mkp make_pair
#define pb push_back
#define arr(zzz) array<ll,zzz>
using namespace std;
#define ll long long
const int maxn=5e2+;
int a[maxn][maxn];
const int inf=0x3f3f3f3f;
int main(){
int n,m;
scanf("%d%d",&n,&m);
int now=;
for(int i=;i<n;i++){
for(int j=;j<m;j++){
scanf("%d",&a[i][j]);
}
}
for(int i=;i<n;i++)now^=a[i][];
if(now!=){
cout<<"TAK\n";
for(int i=;i<n;i++)cout<<<<" ";
return ;
}
else {
for(int i=;i<n;i++){
for(int j=;j<m;j++){
if(a[i][j]!=a[i][]){
cout<<"TAK\n";
for(int k=;k<n;k++){
if(k!=i)cout<<<<" ";
else cout<<j+<<" ";
}
return ; }
}
}
cout<<"NIE\n"; }
return ;
}

Codeforces Round #553 (Div. 2)B. Dima and a Bad XOR 思维构造+异或警告的更多相关文章

  1. Codeforces Round #529 (Div. 3) E. Almost Regular Bracket Sequence (思维)

    Codeforces Round #529 (Div. 3) 题目传送门 题意: 给你由左右括号组成的字符串,问你有多少处括号翻转过来是合法的序列 思路: 这么考虑: 如果是左括号 1)整个序列左括号 ...

  2. Codeforces Round #553 (Div. 2)

    传送门 A. Maxim and Biology 题意: 给出一个串s,问最少需要多少步操作使得串s包含"ACTG"这个子串,输出最少操作次数: 题解: 枚举每个位置 i,求出将 ...

  3. Codeforces Round #553 (Div. 2) 题解

    昨晚深夜修仙上紫记,虽然不错还是很有遗憾的. A. Maxim and Biology 看完就会做的题,然而手速跟不上 #include<cstdio> #include<iostr ...

  4. Codeforces Round #553 (Div. 2)/codeforces1151

    CodeForces1151 Maxim and Biology 解析: 题目大意 每次可以使原串中的一个字符\(+1/-1\),\(Z + 1\to A, A -1\to Z\),求至少修改多少次可 ...

  5. Codeforces Round #167 (Div. 2) D. Dima and Two Sequences 排列组合

    题目链接: http://codeforces.com/problemset/problem/272/D D. Dima and Two Sequences time limit per test2 ...

  6. Codeforces Round #324 (Div. 2) D. Dima and Lisa 哥德巴赫猜想

    D. Dima and Lisa Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/584/probl ...

  7. Codeforces Round #208 (Div. 2) 358D Dima and Hares

    题目链接:http://codeforces.com/problemset/problem/358/D 开始题意理解错,整个就跪了= = 题目大意:从1到n的位置取数,取数的得到值与周围的数有没有取过 ...

  8. Codeforces Round #214 (Div. 2) C. Dima and Salad (背包变形)

    C. Dima and Salad time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  9. Codeforces Round #553 (Div. 2) D题

    题目网址:http://codeforces.com/contest/1151/problem/D 题目大意:给出n组数对,(ai , bi),调整这n组数对的位置,最小化 ∑(ai*( i -1)+ ...

随机推荐

  1. JS forEach()与map() 用法(转载)

    JavaScript中的数组遍历forEach()与map()方法以及兼容写法   原理: 高级浏览器支持forEach方法语法:forEach和map都支持2个参数:一个是回调函数(item,ind ...

  2. MVC在filter中如何获取控制器名称和Action名称

    使用ActionExecutingContext对象可以获取控制器名称.Action名称.参数名称以及参数值.路由和Action返回值不影响结果. 在代码中 [AttributeUsage(Attri ...

  3. thinkphp 分页Pages

    位置: Thinkphp/Library/Think/Pages 或Page pages.class.php <?php // +-------------------------------- ...

  4. window搭建Tomcat服务

    1.启动cmd 进入到Tomcat目录 D:\xy_ybb\XY\serviceXY\apache-tomcat-7.0.81\bin>cd D:\xy_ybb\XY\tomcat\apache ...

  5. HDU1402(fft)

    A * B Problem Plus Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

  6. idea加载JSTL库

    被这个错误缠了很长时间,偶然解决.eclipse for EE里导入JSTL没有问题,在JetIdea里就报classnotfound的异常. 解决方案:打包方式fix一下 新建library fil ...

  7. EasyUI 通过 Combobox 实现 AutoComplete 效果

    朋友在做一个web程序,用的EasyUI框架,让我帮忙实现一个自动提示功能.由于之前我也没用过EasyUI框架,就想到了jQueryUI有 AutoComplete 插件,就想直接拿过来用. 但当我将 ...

  8. Android 系统中运行jar文件

    在android系统中运行jar操作步骤: 1.       打包编译jar包 2.       将jar包导入android设备中 adb push test.jar  /data/local/tm ...

  9. Unity Profiler连接Android真机调试

    Profiler在Editor模式就可以观看性能消耗,但是毕竟电脑配置高,跟手机真机环境还是有区别.实际开发中的优化还是推荐用真机测试. 因为IOS一般比Android手机的配置高,在Android平 ...

  10. AngularJS简单入门

    什么是AngularJS AngularJS是一款优秀的前端JS框架,是Google多款产品之一,简称ng. ng有着诸多特性,最为核心的是:MVVM.模块化.自动化双向数据绑定.语义化标签.依赖注入 ...