This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, k;
ll read() {
ll num = 0;
for (int i = n-1; i >= 0; i--) {
char c; cin >> c;
if (c == '1') {
num |= (1 << i);
}
}
return num;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n >> k;
map<ll, int> deadCt;
set<ll> dead;
queue<ll> q;
ll a, b; a = read(), b = read();
for (int i = 0; i < k; i++) {
ll x = read();
dead.insert(x);
q.push(x);
}
while (!q.empty()) {
ll x = q.front(); q.pop();
for (int i = 0; i < n; i++) {
ll y = x ^ (1 << i);
deadCt[y]++;
if (deadCt[y] == n && !dead.count(y)) {
q.push(y);
dead.insert(y);
}
}
}
if (dead.count(a) || dead.count(b)) cout << "NIE" << "\n";
else cout << "TAK" << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |