# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
230143 |
2020-05-08T17:11:32 Z |
xiaowuc1 |
Walk (POI13_spa) |
C++14 |
|
2961 ms |
53624 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;
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
// http://xorshift.di.unimi.it/splitmix64.c
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
};
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, custom_hash> s;
ll all[1000001];
bool done = false;
bool finite(ll src, ll snk) {
s.clear();
int allsz = 0;
all[allsz++] = src;
s.insert(src);
for(int i = 0; i < allsz && allsz <= 1000000; i++) {
for(int j = 0; j < n && allsz <= 1000000; 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[allsz++] = curr;
}
}
if(s.count(snk)) done = true;
return !s.count(snk) && allsz <= 1000000;
}
void solve() {
cin >> n >> k;
ll src = parse();
ll snk = parse();
bad.reserve(k);
s.reserve(1000001);
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 |
10 ms |
8576 KB |
Output is correct |
2 |
Correct |
13 ms |
8704 KB |
Output is correct |
3 |
Correct |
13 ms |
8704 KB |
Output is correct |
4 |
Correct |
22 ms |
9216 KB |
Output is correct |
5 |
Correct |
20 ms |
9216 KB |
Output is correct |
6 |
Correct |
10 ms |
8576 KB |
Output is correct |
7 |
Correct |
11 ms |
8576 KB |
Output is correct |
8 |
Correct |
11 ms |
8576 KB |
Output is correct |
9 |
Correct |
11 ms |
8576 KB |
Output is correct |
10 |
Correct |
11 ms |
8576 KB |
Output is correct |
11 |
Correct |
73 ms |
10488 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
105 ms |
11000 KB |
Output is correct |
2 |
Correct |
348 ms |
14328 KB |
Output is correct |
3 |
Correct |
2961 ms |
49144 KB |
Output is correct |
4 |
Correct |
1739 ms |
52856 KB |
Output is correct |
5 |
Correct |
1701 ms |
52728 KB |
Output is correct |
6 |
Correct |
640 ms |
53368 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
8576 KB |
Output is correct |
2 |
Correct |
748 ms |
47864 KB |
Output is correct |
3 |
Correct |
1640 ms |
47816 KB |
Output is correct |
4 |
Correct |
1580 ms |
47736 KB |
Output is correct |
5 |
Correct |
739 ms |
47808 KB |
Output is correct |
6 |
Correct |
1190 ms |
47740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
8704 KB |
Output is correct |
2 |
Correct |
11 ms |
8576 KB |
Output is correct |
3 |
Correct |
1196 ms |
47828 KB |
Output is correct |
4 |
Correct |
1236 ms |
47864 KB |
Output is correct |
5 |
Correct |
554 ms |
47740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
9600 KB |
Output is correct |
2 |
Correct |
776 ms |
48632 KB |
Output is correct |
3 |
Correct |
1568 ms |
48632 KB |
Output is correct |
4 |
Correct |
1382 ms |
49912 KB |
Output is correct |
5 |
Correct |
29 ms |
10880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
51 ms |
9464 KB |
Output is correct |
2 |
Correct |
608 ms |
47992 KB |
Output is correct |
3 |
Correct |
1255 ms |
47864 KB |
Output is correct |
4 |
Correct |
1356 ms |
48504 KB |
Output is correct |
5 |
Correct |
642 ms |
51576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
79 ms |
10488 KB |
Output is correct |
2 |
Correct |
1237 ms |
49320 KB |
Output is correct |
3 |
Correct |
2259 ms |
53624 KB |
Output is correct |
4 |
Correct |
2089 ms |
51520 KB |
Output is correct |
5 |
Correct |
59 ms |
12408 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
83 ms |
10360 KB |
Output is correct |
2 |
Correct |
76 ms |
9848 KB |
Output is correct |
3 |
Correct |
2012 ms |
48504 KB |
Output is correct |
4 |
Correct |
916 ms |
49144 KB |
Output is correct |
5 |
Correct |
934 ms |
48888 KB |
Output is correct |