Submission #316348

#TimeUsernameProblemLanguageResultExecution timeMemory
316348thecodingwizardWalk (POI13_spa)C++11
0 / 100
5080 ms221752 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...