fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4. int n, m;//number of rows and columns
  5. cin>>n>>m;
  6.  
  7. vector<vector<int> > v(n, vector<int>(m, 0));
  8. for(int i=0; i<n; i++){
  9. vector<int> temp(m, 0);
  10. for(int j=0; j<m; j++){
  11. cin>>temp[j];
  12. }
  13. v.push_back(temp);
  14. }
  15.  
  16. int exor=v[0][0];
  17.  
  18. for(int i=1; i<n; i++){
  19. exor=exor^v[i][0];
  20. }
  21.  
  22. vector<int> ind(n, 0);
  23.  
  24. if(exor<=0){
  25. //find an element in rows which is not equal to first element
  26. int f=0;//element not found yet
  27. for(int i=0; i<n; i++){
  28. int temp=v[i][0];
  29. for(int j=1; i<m; i++){
  30. if(v[i][j]!=temp){
  31. f=1;
  32. ind[i]=j;
  33. break;
  34. }
  35. }
  36. }
  37. if(f==0){
  38. cout<<"NIE"<<endl;
  39. }
  40. else{
  41. cout<<"YES"<<endl;
  42. cout<<"TAK"<<endl;
  43. for(int i=0; i<n; i++){
  44. cout<<ind[i];
  45. }
  46. }
  47.  
  48. }
  49.  
  50. else{
  51. cout<<"TAK"<<endl;
  52. for(int i=0; i<n; i++){
  53. cout<<ind[i];
  54. }
  55. }
  56. return 0;
  57. }
Success #stdin #stdout 0s 15240KB
stdin
2 3
7 7 7
7 7 10

stdout
TAK
00