# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
316604 |
2020-10-26T22:40:20 Z |
thecodingwizard |
Walk (POI13_spa) |
C++11 |
|
5000 ms |
82920 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, k;
set<ll> dead;
ll read() {
ll num = 0;
for (int i = n-1; i >= 0; i--) {
char c; cin >> c;
if (c == '1') {
num |= (1LL << i);
}
}
return num;
}
// return true if a can reach b or if a can reach at least ct nodes
bool solve(ll a, ll b, int ct) {
set<ll> vis;
queue<ll> q; q.push(a); vis.insert(a);
while (!q.empty()) {
ll u = q.front(); q.pop();
for (int i = 0; i < n; i++) {
ll v = u ^ (1LL << i);
if (vis.count(v) || dead.count(v)) continue;
vis.insert(v);
if (v == b) return true;
q.push(v);
}
}
return false;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n >> k; assert(n<=22);
ll a, b; a = read(), b = read();
for (int i = 0; i < k; i++) {
ll x = read();
dead.insert(x);
}
cout << (solve(a, b, n*k+1) && solve(b, a, n*k+1) ? "TAK" : "NIE") << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
512 KB |
Output is correct |
3 |
Correct |
7 ms |
520 KB |
Output is correct |
4 |
Correct |
58 ms |
1176 KB |
Output is correct |
5 |
Correct |
28 ms |
1152 KB |
Output is correct |
6 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
485 ms |
12560 KB |
Output is correct |
2 |
Correct |
1060 ms |
14200 KB |
Output is correct |
3 |
Execution timed out |
5059 ms |
82920 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |