# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1011560 |
2024-06-30T15:34:26 Z |
dondurma |
Walk (POI13_spa) |
C++17 |
|
4214 ms |
262144 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#pragma GCC optimization("g", on)
#pragma GCC optimization("03")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse,-fgcse-lm")
#pragma GCC optimize("-ftree-pre,-ftree-vrp")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
ll n, k;
unordered_map<ll, bool> d;
ll read() {
string s; cin >> s;
ll x = 0;
for (int i = 0;i < n;i++) {
if (s[i] == '1') x += (1ll << i);
}
return x;
}
bool solve(ll x, ll y) {
ll cnt = min(n * k + 1, 3000000ll);
unordered_map<ll, bool> vis;
queue<ll> q;
q.push(x);
cnt--;
vis[x] = 1;
while (!q.empty()) {
ll v = q.front();
q.pop();
for (int i = 0;i < n;i++) {
ll t = v ^ (1ll << i);
if (t == y) return 1;
if (!vis[t] && !d[t]) {
cnt--;
if (!cnt) {
return 1;
}
vis[t] = 1;
q.push(t);
}
}
}
return 0;
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
cin >> n >> k;
ll x = read(), y = read();
for (int i = 1;i <= k;i++) {
ll t = read();
d[t] = 1;
}
cout << (solve(x, y) && solve(y, x) ? "TAK" : "NIE");
}
Compilation message
spa.cpp:6: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
6 | #pragma GCC optimization("g", on)
|
spa.cpp:7: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
7 | #pragma GCC optimization("03")
|
spa.cpp:8: warning: ignoring '#pragma comment ' [-Wunknown-pragmas]
8 | #pragma comment(linker, "/stack:200000000")
|
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
6 ms |
1984 KB |
Output is correct |
5 |
Correct |
5 ms |
1628 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
50 ms |
11136 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
104 ms |
17016 KB |
Output is correct |
2 |
Correct |
133 ms |
23420 KB |
Output is correct |
3 |
Runtime error |
2484 ms |
262144 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
45 ms |
12896 KB |
Output is correct |
3 |
Correct |
104 ms |
18748 KB |
Output is correct |
4 |
Correct |
17 ms |
4292 KB |
Output is correct |
5 |
Correct |
11 ms |
4624 KB |
Output is correct |
6 |
Correct |
2 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
860 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
53 ms |
14200 KB |
Output is correct |
4 |
Correct |
138 ms |
27360 KB |
Output is correct |
5 |
Correct |
95 ms |
24744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
59 ms |
7616 KB |
Output is correct |
2 |
Runtime error |
1900 ms |
262144 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
53 ms |
7620 KB |
Output is correct |
2 |
Correct |
949 ms |
110716 KB |
Output is correct |
3 |
Correct |
2455 ms |
162304 KB |
Output is correct |
4 |
Runtime error |
1909 ms |
262144 KB |
Execution killed with signal 9 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
101 ms |
15808 KB |
Output is correct |
2 |
Runtime error |
2228 ms |
262144 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
103 ms |
15996 KB |
Output is correct |
2 |
Correct |
37 ms |
6860 KB |
Output is correct |
3 |
Correct |
4214 ms |
241908 KB |
Output is correct |
4 |
Correct |
54 ms |
8640 KB |
Output is correct |
5 |
Runtime error |
2019 ms |
262144 KB |
Execution killed with signal 9 |
6 |
Halted |
0 ms |
0 KB |
- |