Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- const int NMMAX = 501;
- int a[NMMAX][NMMAX], secv_sol[NMMAX];
- int main()
- {
- int n, m;
- cin >> n >> m;
- for (int i = 1; i <= n; i++)
- for (int j = 1; j <= m; j++)
- cin >> a[i][j];
- for (int k = 1; k <= m; k++) {
- int no_secv_sol = 0, xor_product = a[1][k];
- secv_sol[++no_secv_sol] = k;
- for (int i = 2; i <= n; i++) {
- bool found = false;
- for (int j = 1; j <= m && found == false; j++) {
- if (a[i][j] != xor_product) {
- secv_sol[++no_secv_sol] = j;
- found = true;
- xor_product = xor_product ^ a[i][j];
- }
- }
- if (found == false) {xor_product = xor_product ^ a[i][1]; secv_sol[++no_secv_sol] = 1;}
- }
- if (no_secv_sol == n && xor_product != 0)
- {
- cout << "TAK" << '\n';
- for (int i = 1; i <= n; i++) cout << secv_sol[i] << " ";
- return 0;
- }
- }
- cout << "NIE" << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement