# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1011565 |
2024-06-30T15:39:43 Z |
dondurma |
Walk (POI13_spa) |
C++17 |
|
4623 ms |
200708 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_set<ll> 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 = 3000000;
unordered_set<ll> vis;
queue<ll> q;
q.push(x);
cnt--;
vis.insert(x);
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.count(t) && !d.count(t)) {
cnt--;
if (!cnt) {
return 1;
}
vis.insert(t);
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.insert(t);
}
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 |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
428 KB |
Output is correct |
4 |
Correct |
7 ms |
1076 KB |
Output is correct |
5 |
Correct |
4 ms |
1112 KB |
Output is correct |
6 |
Correct |
0 ms |
344 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 |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
50 ms |
12860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
84 ms |
14200 KB |
Output is correct |
2 |
Correct |
135 ms |
14784 KB |
Output is correct |
3 |
Correct |
4623 ms |
178540 KB |
Output is correct |
4 |
Correct |
1415 ms |
92916 KB |
Output is correct |
5 |
Correct |
1302 ms |
91176 KB |
Output is correct |
6 |
Correct |
21 ms |
4968 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1887 ms |
180520 KB |
Output is correct |
3 |
Correct |
3454 ms |
183132 KB |
Output is correct |
4 |
Correct |
3698 ms |
182428 KB |
Output is correct |
5 |
Correct |
1957 ms |
179772 KB |
Output is correct |
6 |
Correct |
3401 ms |
187088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
3320 ms |
186948 KB |
Output is correct |
4 |
Correct |
3379 ms |
187288 KB |
Output is correct |
5 |
Correct |
1610 ms |
184416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
5724 KB |
Output is correct |
2 |
Correct |
2004 ms |
187824 KB |
Output is correct |
3 |
Correct |
3682 ms |
190548 KB |
Output is correct |
4 |
Correct |
3478 ms |
187500 KB |
Output is correct |
5 |
Correct |
15 ms |
2076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
4964 KB |
Output is correct |
2 |
Correct |
1851 ms |
185000 KB |
Output is correct |
3 |
Correct |
3535 ms |
198980 KB |
Output is correct |
4 |
Correct |
3362 ms |
200708 KB |
Output is correct |
5 |
Correct |
1870 ms |
186756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
68 ms |
9924 KB |
Output is correct |
2 |
Correct |
2240 ms |
183992 KB |
Output is correct |
3 |
Correct |
4228 ms |
186688 KB |
Output is correct |
4 |
Correct |
3799 ms |
181064 KB |
Output is correct |
5 |
Correct |
40 ms |
5316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
73 ms |
9764 KB |
Output is correct |
2 |
Correct |
35 ms |
3940 KB |
Output is correct |
3 |
Correct |
3634 ms |
180104 KB |
Output is correct |
4 |
Correct |
46 ms |
5828 KB |
Output is correct |
5 |
Correct |
2053 ms |
183496 KB |
Output is correct |