Submission #1116420

#TimeUsernameProblemLanguageResultExecution timeMemory
1116420biximoWalk (POI13_spa)C++17
0 / 100
100 ms17224 KiB
#include <bits/stdc++.h> using namespace std; const int N = 300005, INF = 1000000000; int n, k; long long x, y; set<long long> nt; long long getNum(string s) { long long v = 0; for(char i: s) { v = v*2+i-'0'; } return v; } int getSz(long long st) { queue<long long> que; unordered_set<long long> vs; que.push(st); vs.insert(st); while(que.size() && vs.size() <= 5000000) { long long c =que.front(); que.pop(); for(int i = 0; i < n; i ++) { if(c&1LL<<i) continue; if(vs.count(c|1LL<<i)) continue; if(nt.count(c|1LL<<i)) continue; vs.insert(c|1LL<<i); que.push(c|1LL<<i); } } return vs.size(); } bool contains(long long st, long long gl) { queue<long long> que; unordered_set<long long> vs; que.push(st); vs.insert(st); while(que.size() && vs.size() <= 5000000) { long long c =que.front(); que.pop(); for(int i = 0; i < n; i ++) { if(c&1LL<<i) continue; if(vs.count(c|1LL<<i)) continue; if(nt.count(c|1LL<<i)) continue; vs.insert(c|1LL<<i); que.push(c|1LL<<i); } } return vs.count(gl); } int main() { cin.tie(0)->sync_with_stdio(0); cin >> n >> k; string a, b; cin >> a >> b; x = getNum(a); y = getNum(b); while(k--) { cin >> a; nt.insert(getNum(a)); } if(getSz(x) >= 5000000 && getSz(y) >= 5000000 || contains(x,y)) { cout << "TAK\n"; } else { cout << "NIE\n"; } }

Compilation message (stderr)

spa.cpp: In function 'int main()':
spa.cpp:57:28: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   57 |     if(getSz(x) >= 5000000 && getSz(y) >= 5000000 || contains(x,y)) {
      |        ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...