Submission #1011556

#TimeUsernameProblemLanguageResultExecution timeMemory
1011556dondurmaWalk (POI13_spa)C++17
62 / 100
5053 ms259868 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #pragma GCC optimization("g", on) #pragma GCC optimization("03") #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC optimize("inline") #pragma GCC optimize("-fgcse,-fgcse-lm") #pragma GCC optimize("-ftree-pre,-ftree-vrp") #pragma GCC optimize("-ffast-math") #pragma GCC optimize("-fipa-sra") #pragma GCC optimize("-fpeephole2") #pragma GCC optimize("-fsched-spec") #pragma GCC optimize("Ofast,no-stack-protector") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") #pragma GCC optimize("unroll-loops") ll n, k; unordered_set<ll> d; ll read() { string s; cin >> s; ll x = 0; for (int i = 0;i < n;i++) { if (s[i] == '1') x += (1ll << i); } return x; } bool solve(ll x, ll y) { ll cnt = n * k + 1; unordered_set<ll> vis; queue<ll> q; q.push(x); cnt--; vis.insert(x); while (!q.empty()) { ll v = q.front(); q.pop(); for (int i = 0;i < n;i++) { ll t = v ^ (1ll << i); if (t == y) return 1; if (!vis.count(t) && !d.count(t)) { cnt--; if (!cnt) { return 1; } vis.insert(t); q.push(t); } } } return 0; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n >> k; ll x = read(), y = read(); for (int i = 1;i <= k;i++) { ll t = read(); d.insert(t); } cout << (solve(x, y) && solve(y, x) ? "TAK" : "NIE"); }

Compilation message (stderr)

spa.cpp:6: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    6 | #pragma GCC optimization("g", on)
      | 
spa.cpp:7: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    7 | #pragma GCC optimization("03")
      | 
spa.cpp:8: warning: ignoring '#pragma comment ' [-Wunknown-pragmas]
    8 | #pragma comment(linker, "/stack:200000000")
      |
#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...