답안 #1011563

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1011563 2024-06-30T15:37:51 Z dondurma Walk (POI13_spa) C++17
100 / 100
3535 ms 139748 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) {
    int cnt = min(n * k + 1, 2500000ll);
    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")
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 7 ms 1116 KB Output is correct
5 Correct 4 ms 1112 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 49 ms 12620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 97 ms 14048 KB Output is correct
2 Correct 140 ms 14360 KB Output is correct
3 Correct 3535 ms 116260 KB Output is correct
4 Correct 1402 ms 92536 KB Output is correct
5 Correct 1460 ms 92332 KB Output is correct
6 Correct 25 ms 8836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 33 ms 7308 KB Output is correct
3 Correct 61 ms 8024 KB Output is correct
4 Correct 14 ms 2408 KB Output is correct
5 Correct 7 ms 2488 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 860 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 38 ms 6916 KB Output is correct
4 Correct 125 ms 15788 KB Output is correct
5 Correct 53 ms 13948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 9852 KB Output is correct
2 Correct 1609 ms 128148 KB Output is correct
3 Correct 3133 ms 139748 KB Output is correct
4 Correct 1893 ms 111400 KB Output is correct
5 Correct 17 ms 3768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 9116 KB Output is correct
2 Correct 488 ms 62260 KB Output is correct
3 Correct 897 ms 68020 KB Output is correct
4 Correct 2571 ms 137868 KB Output is correct
5 Correct 1312 ms 125504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 12484 KB Output is correct
2 Correct 1816 ms 124572 KB Output is correct
3 Correct 3396 ms 126056 KB Output is correct
4 Correct 3038 ms 132448 KB Output is correct
5 Correct 43 ms 7516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 12236 KB Output is correct
2 Correct 38 ms 5216 KB Output is correct
3 Correct 1859 ms 92056 KB Output is correct
4 Correct 46 ms 8132 KB Output is correct
5 Correct 1618 ms 123020 KB Output is correct