Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.11 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. const int NMMAX = 501;
  7. int a[NMMAX][NMMAX], secv_sol[NMMAX];
  8.  
  9. int main()
  10. {
  11.     int n, m;
  12.     cin >> n >> m;
  13.     for (int i = 1; i <= n; i++)
  14.         for (int j = 1; j <= m; j++)
  15.             cin >> a[i][j];
  16.     for (int k = 1; k <= m; k++) {
  17.         int no_secv_sol = 0, xor_product = a[1][k];
  18.         secv_sol[++no_secv_sol] = k;
  19.         for (int i = 2; i <= n; i++) {
  20.             bool found = false;
  21.             for (int j = 1; j <= m && found == false; j++) {
  22.                 if (a[i][j] != xor_product) {
  23.                     secv_sol[++no_secv_sol] = j;
  24.                     found = true;
  25.                     xor_product = xor_product ^ a[i][j];
  26.                 }
  27.             }
  28.             if (found == false) {xor_product = xor_product ^ a[i][1]; secv_sol[++no_secv_sol] = 1;}
  29.         }
  30.         if (no_secv_sol == n && xor_product != 0)
  31.         {
  32.             cout << "TAK" << '\n';
  33.             for (int i = 1; i <= n; i++) cout << secv_sol[i] << " ";
  34.             return 0;
  35.         }
  36.     }
  37.     cout << "NIE" << '\n';
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement