zoukankan      html  css  js  c++  java
  • Codeforces Round #553 (Div. 2)B. Dima and a Bad XOR 思维构造+异或警告

    题意:

    给出一个矩阵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

     1 #include<bits/stdc++.h>
     2 #define FOR(i,f_start,f_end) for(int i=f_start;i<=f_end;i++)
     3 #define MS(arr,arr_value) memset(arr,arr_value,sizeof(arr)) 
     4 #define F first 
     5 #define S second
     6 #define pii pair<int ,int >
     7 #define mkp make_pair
     8 #define pb push_back
     9 #define arr(zzz) array<ll,zzz>
    10 using namespace std;
    11 #define ll long long 
    12 const int maxn=5e2+4;
    13 int a[maxn][maxn];
    14 const int inf=0x3f3f3f3f;
    15 int main(){
    16     int n,m;
    17     scanf("%d%d",&n,&m);
    18     int now=0;
    19     for(int i=0;i<n;i++){
    20         for(int j=0;j<m;j++){
    21             scanf("%d",&a[i][j]);
    22         }
    23     }
    24     for(int i=0;i<n;i++)now^=a[i][0];
    25     if(now!=0){
    26         cout<<"TAK
    ";
    27         for(int i=0;i<n;i++)cout<<1<<" ";
    28         return 0;
    29     }
    30     else {
    31         for(int i=0;i<n;i++){
    32             for(int j=1;j<m;j++){
    33                 if(a[i][j]!=a[i][0]){
    34                     cout<<"TAK
    ";
    35                     for(int k=0;k<n;k++){
    36                         if(k!=i)cout<<1<<" ";
    37                         else cout<<j+1<<" ";
    38                     }
    39                     return 0;
    40                 
    41                 }
    42             }
    43         }
    44         cout<<"NIE
    ";
    45     
    46     }
    47      return 0;
    48 }
    View Code
  • 相关阅读:
    Solr环境配置
    SolrJ解析MoreLikeThis查询结果
    思维导图软件PersonalBrain 6.0.6.4破解版使用
    离散对数-详解
    转:pptp和l2tp的区别
    DiffieHellman Key Exchange (DH)源代码
    磁盘IOPS计算
    转:TCP/IP Network Performance Benchmarks and Tools
    转:弄清楚你的业务类型——OLTP or OLAP
    U8软件的端口
  • 原文地址:https://www.cnblogs.com/ttttttttrx/p/10792896.html
Copyright © 2011-2022 走看看