# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
339554 |
2020-12-25T15:51:08 Z |
Alex_tz307 |
Walk (POI13_spa) |
C++17 |
|
3644 ms |
54172 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N, K;
ll x, y;
unordered_set<ll> forbidden;
bool graphSearch(ll s, ll d, int cnt) {
unordered_set<ll> vis;
queue<ll> Q;
Q.emplace(s);
vis.insert(s);
--cnt;
while(!Q.empty()) {
ll v = Q.front();
Q.pop();
for(int i = 0; i < N; ++i) {
ll next = v ^ (1LL << i);
if(next == d)
return true;
if(!forbidden.count(next) && !vis.count(next)) {
--cnt;
if(cnt == 0)
return true;
Q.emplace(next);
vis.insert(next);
}
}
}
return false;
}
bool solve(ll s, ll d) {
int bound = 1e6;
bool a = graphSearch(s, d, bound),
b = graphSearch(d, s, bound);
return a && b;
}
ll readBin() {
string s;
cin >> s;
ll nr = 0;
for(int i = N - 1; i >= 0; --i)
if(s[i] == '1')
nr += (1LL << (N - i - 1));
return nr;
}
void read() {
cin >> N >> K;
x = readBin(), y = readBin();
for(int i = 0; i < K; ++i) {
ll a;
a = readBin();
forbidden.insert(a);
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
read();
if(solve(x, y))
cout << "TAK";
else
cout << "NIE";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
2 ms |
492 KB |
Output is correct |
3 |
Correct |
3 ms |
492 KB |
Output is correct |
4 |
Correct |
19 ms |
1004 KB |
Output is correct |
5 |
Correct |
10 ms |
1004 KB |
Output is correct |
6 |
Correct |
0 ms |
364 KB |
Output is correct |
7 |
Correct |
0 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
0 ms |
364 KB |
Output is correct |
10 |
Correct |
0 ms |
364 KB |
Output is correct |
11 |
Correct |
109 ms |
9396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
172 ms |
10676 KB |
Output is correct |
2 |
Correct |
2100 ms |
51444 KB |
Output is correct |
3 |
Correct |
3644 ms |
51856 KB |
Output is correct |
4 |
Correct |
2045 ms |
53748 KB |
Output is correct |
5 |
Correct |
2104 ms |
53876 KB |
Output is correct |
6 |
Correct |
45 ms |
9616 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1128 ms |
46576 KB |
Output is correct |
3 |
Correct |
2227 ms |
47024 KB |
Output is correct |
4 |
Correct |
2248 ms |
46748 KB |
Output is correct |
5 |
Correct |
1031 ms |
46576 KB |
Output is correct |
6 |
Correct |
1956 ms |
51996 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
492 KB |
Output is correct |
2 |
Correct |
947 ms |
47600 KB |
Output is correct |
3 |
Correct |
1998 ms |
51868 KB |
Output is correct |
4 |
Correct |
1999 ms |
51956 KB |
Output is correct |
5 |
Correct |
966 ms |
47728 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
92 ms |
5264 KB |
Output is correct |
2 |
Correct |
1453 ms |
51572 KB |
Output is correct |
3 |
Correct |
2750 ms |
52320 KB |
Output is correct |
4 |
Correct |
2151 ms |
49900 KB |
Output is correct |
5 |
Correct |
1039 ms |
49776 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
76 ms |
4492 KB |
Output is correct |
2 |
Correct |
1064 ms |
48720 KB |
Output is correct |
3 |
Correct |
2043 ms |
52852 KB |
Output is correct |
4 |
Correct |
2326 ms |
54172 KB |
Output is correct |
5 |
Correct |
1221 ms |
50416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
140 ms |
8884 KB |
Output is correct |
2 |
Correct |
1839 ms |
52980 KB |
Output is correct |
3 |
Correct |
3235 ms |
53392 KB |
Output is correct |
4 |
Correct |
3113 ms |
50484 KB |
Output is correct |
5 |
Correct |
1545 ms |
50420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
146 ms |
8664 KB |
Output is correct |
2 |
Correct |
1376 ms |
48664 KB |
Output is correct |
3 |
Correct |
2747 ms |
48928 KB |
Output is correct |
4 |
Correct |
89 ms |
7312 KB |
Output is correct |
5 |
Correct |
1542 ms |
52004 KB |
Output is correct |