# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
230140 |
2020-05-08T17:01:51 Z |
xiaowuc1 |
Walk (POI13_spa) |
C++14 |
|
5000 ms |
244568 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 <unordered_set>
#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;
}
vector<ll> bad;
int n, k;
unordered_set<ll> s;
vector<ll> all;
bool done = false;
bool finite(ll src, ll snk) {
s.clear();
all.clear();
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)) continue;
auto it = lower_bound(all(bad), curr);
if(it != bad.end() && *it == curr) continue;
s.insert(curr);
all.push_back(curr);
}
}
if(s.count(snk)) done = true;
return !s.count(snk) && sz(all) <= n*k;
}
void solve() {
cin >> n >> k;
all.reserve(n*k+n+1);
ll src = parse();
ll snk = parse();
bad.reserve(k);
for(int i = 0; i < k; i++) {
bad.push_back(parse());
}
sort(all(bad));
if(finite(src, snk)) {
cout << "NIE\n";
return;
}
if(!done && finite(snk, src)) {
cout << "NIE\n";
return;
}
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 |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
6 ms |
512 KB |
Output is correct |
4 |
Correct |
12 ms |
1152 KB |
Output is correct |
5 |
Correct |
12 ms |
1152 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
69 ms |
2296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
94 ms |
2808 KB |
Output is correct |
2 |
Correct |
288 ms |
8460 KB |
Output is correct |
3 |
Execution timed out |
5110 ms |
235572 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
55 ms |
7612 KB |
Output is correct |
3 |
Correct |
94 ms |
7612 KB |
Output is correct |
4 |
Correct |
25 ms |
2352 KB |
Output is correct |
5 |
Correct |
16 ms |
2352 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
308 KB |
Output is correct |
3 |
Correct |
56 ms |
5000 KB |
Output is correct |
4 |
Correct |
264 ms |
14252 KB |
Output is correct |
5 |
Correct |
137 ms |
14348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
1400 KB |
Output is correct |
2 |
Correct |
4348 ms |
244568 KB |
Output is correct |
3 |
Execution timed out |
5107 ms |
244500 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
1144 KB |
Output is correct |
2 |
Correct |
888 ms |
63652 KB |
Output is correct |
3 |
Correct |
1605 ms |
63768 KB |
Output is correct |
4 |
Execution timed out |
5099 ms |
163932 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
69 ms |
2168 KB |
Output is correct |
2 |
Execution timed out |
5026 ms |
235780 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
68 ms |
2168 KB |
Output is correct |
2 |
Correct |
73 ms |
1792 KB |
Output is correct |
3 |
Correct |
2748 ms |
82396 KB |
Output is correct |
4 |
Correct |
3551 ms |
169424 KB |
Output is correct |
5 |
Correct |
3553 ms |
172660 KB |
Output is correct |