At first glance, the subject is difficult to do ah! How do you find to be greater than 0 and a xor ah?
If there is no fixed algorithm ah!
Then do not use a fixed algorithm, using a random algorithm ah! (Konjac bully those ill-informed mind, like me)
Approach is very simple, a random number in each row, brought xor, if possible outputs, then you can not keep looking to find quick time-out have not found directly sentenced to no solution.
8 can not think! I can not think!
Code:
#include<bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
const int maxn = 505;
struct Nodes {
int val, idx;
} a[maxn][maxn];
int n, m;
int answer[maxn], tot;
int read() {
int ans = 0;
char ch = getchar();
while(ch > '9' || ch < '0') ch = getchar();
while(ch >= '0' && ch <= '9') ans = ans * 10 + ch - '0', ch = getchar();
return ans;
}
int main() {
srand(19260817);
n = read(), m = read();
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
a[i][j].val = read(), a[i][j].idx = j;
}
}
for(int t = 1; t <= 20000; t++) {
int res = 0; tot = 0;
for(int i = 1; i <= n; i++) {
int idx = rand() % m + 1;
res ^= a[i][idx].val; answer[++tot] = a[i][idx].idx;
}
if(res) {
puts("TAK");
for(int i = 1; i <= n; i++) printf("%d ", answer[i]);
puts("");
return 0;
}
}
puts("NIE");
return 0;
}