# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
230134 |
2020-05-08T16:55:36 Z |
xiaowuc1 |
Walk (POI13_spa) |
C++14 |
|
5000 ms |
248464 KB |
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>
using namespace std;
// BEGIN NO SAD
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define derr if(1) cerr
typedef vector<int> vi;
// END NO SAD
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<ll>> matrix;
typedef pair<int, pii> state;
ll parse() {
string s;
cin >> s;
ll ret = 0;
for(int i = 0; i < sz(s); i++) {
ret <<= 1;
ret |= s[i] == '1';
}
return ret;
}
set<ll> bad;
int n, k;
bool finite(ll src, ll snk) {
set<ll> s;
vector<ll> all;
all.reserve(n*k+k+1);
all.push_back(src);
s.insert(src);
for(int i = 0; i < sz(all) && sz(all) <= n*k; i++) {
for(int j = 0; j < n; j++) {
ll curr = all[i] ^ (1LL << j);
if(s.count(curr) || bad.count(curr)) continue;
s.insert(curr);
all.push_back(curr);
}
}
return !s.count(snk) && sz(all) <= n*k;
}
void solve() {
cin >> n >> k;
ll src = parse();
ll snk = parse();
for(int i = 0; i < k; i++) {
bad.insert(parse());
}
if(finite(src, snk) || finite(snk, src)) cout << "NIE\n";
else cout << "TAK\n";
}
// are there edge cases (N=1?)
// are array sizes proper (scaled by proper constant, for example 2* for koosaga tree)
// integer overflow?
// DS reset properly between test cases
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
508 KB |
Output is correct |
2 |
Correct |
7 ms |
512 KB |
Output is correct |
3 |
Correct |
14 ms |
512 KB |
Output is correct |
4 |
Correct |
56 ms |
1280 KB |
Output is correct |
5 |
Correct |
29 ms |
1272 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
6 ms |
384 KB |
Output is correct |
11 |
Correct |
114 ms |
15224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
408 ms |
12780 KB |
Output is correct |
2 |
Correct |
914 ms |
18308 KB |
Output is correct |
3 |
Execution timed out |
5077 ms |
103068 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
512 KB |
Output is correct |
2 |
Correct |
117 ms |
8184 KB |
Output is correct |
3 |
Correct |
233 ms |
8356 KB |
Output is correct |
4 |
Correct |
58 ms |
2688 KB |
Output is correct |
5 |
Correct |
30 ms |
2688 KB |
Output is correct |
6 |
Correct |
6 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
640 KB |
Output is correct |
2 |
Correct |
6 ms |
512 KB |
Output is correct |
3 |
Correct |
101 ms |
5752 KB |
Output is correct |
4 |
Correct |
420 ms |
15352 KB |
Output is correct |
5 |
Correct |
193 ms |
15480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
102 ms |
6264 KB |
Output is correct |
2 |
Execution timed out |
5087 ms |
248464 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
80 ms |
5352 KB |
Output is correct |
2 |
Correct |
1235 ms |
70776 KB |
Output is correct |
3 |
Correct |
2547 ms |
70988 KB |
Output is correct |
4 |
Execution timed out |
5078 ms |
193928 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
249 ms |
10232 KB |
Output is correct |
2 |
Execution timed out |
5068 ms |
135332 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
265 ms |
9932 KB |
Output is correct |
2 |
Correct |
156 ms |
6136 KB |
Output is correct |
3 |
Execution timed out |
5068 ms |
99324 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |