답안 #1011556

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1011556 2024-06-30T15:21:53 Z dondurma Walk (POI13_spa) C++17
62 / 100
5000 ms 259868 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 = 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

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 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 7 ms 1188 KB Output is correct
5 Correct 4 ms 1116 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 452 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 424 KB Output is correct
11 Correct 50 ms 14588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 104 ms 16252 KB Output is correct
2 Correct 169 ms 16324 KB Output is correct
3 Execution timed out 5029 ms 177844 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 32 ms 7368 KB Output is correct
3 Correct 57 ms 8112 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 552 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 36 ms 6580 KB Output is correct
4 Correct 121 ms 15844 KB Output is correct
5 Correct 56 ms 13988 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 10696 KB Output is correct
2 Correct 3183 ms 237012 KB Output is correct
3 Execution timed out 5053 ms 259868 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 9924 KB Output is correct
2 Correct 492 ms 62108 KB Output is correct
3 Correct 852 ms 68096 KB Output is correct
4 Correct 4042 ms 209084 KB Output is correct
5 Correct 2173 ms 190376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 78 ms 14716 KB Output is correct
2 Correct 3689 ms 217764 KB Output is correct
3 Execution timed out 5042 ms 217760 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 73 ms 14532 KB Output is correct
2 Correct 37 ms 5732 KB Output is correct
3 Correct 1883 ms 92628 KB Output is correct
4 Correct 50 ms 9412 KB Output is correct
5 Correct 2575 ms 187016 KB Output is correct