Submission #1011559

# Submission time Handle Problem Language Result Execution time Memory
1011559 2024-06-30T15:23:18 Z dondurma Walk (POI13_spa) C++17
62 / 100
5000 ms 255212 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, 5000000ll);
    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 2 ms 348 KB Output is correct
4 Correct 6 ms 1116 KB Output is correct
5 Correct 5 ms 1116 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 51 ms 10108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 89 ms 11136 KB Output is correct
2 Correct 150 ms 12512 KB Output is correct
3 Execution timed out 5030 ms 173988 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 34 ms 7132 KB Output is correct
3 Correct 58 ms 7968 KB Output is correct
4 Correct 14 ms 2408 KB Output is correct
5 Correct 9 ms 2232 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 36 ms 6592 KB Output is correct
4 Correct 118 ms 15548 KB Output is correct
5 Correct 54 ms 13772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 5640 KB Output is correct
2 Correct 3738 ms 232148 KB Output is correct
3 Execution timed out 5070 ms 255212 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 46 ms 5000 KB Output is correct
2 Correct 561 ms 60968 KB Output is correct
3 Correct 1173 ms 66748 KB Output is correct
4 Correct 4191 ms 205756 KB Output is correct
5 Correct 2280 ms 186948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 67 ms 9924 KB Output is correct
2 Correct 3623 ms 213132 KB Output is correct
3 Execution timed out 5052 ms 213188 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 69 ms 9804 KB Output is correct
2 Correct 34 ms 3944 KB Output is correct
3 Correct 1858 ms 90840 KB Output is correct
4 Correct 42 ms 5828 KB Output is correct
5 Correct 2512 ms 183352 KB Output is correct