Submission #1011557

# Submission time Handle Problem Language Result Execution time Memory
1011557 2024-06-30T15:22:51 Z dondurma Walk (POI13_spa) C++17
100 / 100
438 ms 35476 KB
#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 = min(n * k + 1, 500000ll);
    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

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 time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 7 ms 1128 KB Output is correct
5 Correct 4 ms 1132 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 46 ms 10076 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 88 ms 11136 KB Output is correct
2 Correct 131 ms 12552 KB Output is correct
3 Correct 438 ms 30564 KB Output is correct
4 Correct 267 ms 33908 KB Output is correct
5 Correct 288 ms 33776 KB Output is correct
6 Correct 23 ms 9936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 31 ms 7112 KB Output is correct
3 Correct 58 ms 7952 KB Output is correct
4 Correct 16 ms 2408 KB Output is correct
5 Correct 7 ms 2440 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 39 ms 6544 KB Output is correct
4 Correct 109 ms 15684 KB Output is correct
5 Correct 51 ms 13692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 61 ms 5572 KB Output is correct
2 Correct 212 ms 30008 KB Output is correct
3 Correct 331 ms 32848 KB Output is correct
4 Correct 279 ms 31932 KB Output is correct
5 Correct 15 ms 4020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 45 ms 4960 KB Output is correct
2 Correct 144 ms 26300 KB Output is correct
3 Correct 270 ms 30704 KB Output is correct
4 Correct 283 ms 30708 KB Output is correct
5 Correct 161 ms 27840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 76 ms 9952 KB Output is correct
2 Correct 293 ms 32700 KB Output is correct
3 Correct 436 ms 35476 KB Output is correct
4 Correct 366 ms 34780 KB Output is correct
5 Correct 39 ms 8132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 76 ms 9928 KB Output is correct
2 Correct 34 ms 3832 KB Output is correct
3 Correct 343 ms 29932 KB Output is correct
4 Correct 43 ms 5832 KB Output is correct
5 Correct 223 ms 30176 KB Output is correct