답안 #316606

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
316606 2020-10-26T22:43:58 Z thecodingwizard Walk (POI13_spa) C++11
36 / 100
5000 ms 262148 KB
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int n, k; 
unordered_set<ll> dead;

ll read() {
    ll num = 0;
    for (int i = n-1; i >= 0; i--) {
        char c; cin >> c;
        if (c == '1') {
            num |= (1LL << i);
        } else {
            assert(c == '0');
        }
    }
    return num;
}

// return true if a can reach b or if a can reach at least ct nodes
bool solve(ll a, ll b, int ct) {
    unordered_set<ll> vis;
    queue<ll> q; q.push(a); vis.insert(a);
    while (!q.empty()) {
        ll u = q.front(); q.pop();
        for (int i = 0; i < n; i++) {
            ll v = u ^ (1LL << i);
            if (vis.count(v) || dead.count(v)) continue;
            vis.insert(v);
            if ((int)vis.size() >= ct || v == b) return true;
            q.push(v);
        }
    }
    return false;
}

int main() {
    cin.tie(0)->sync_with_stdio(0);

    cin >> n >> k;

    ll a, b; a = read(), b = read();
    if (a == b) {
        cout << "TAK" << endl;
        return 0;
    }
    for (int i = 0; i < k; i++) {
        ll x = read();
        dead.insert(x);
    }

    cout << (solve(a, b, n*k+1) && solve(b, a, n*k+1) ? "TAK" : "NIE") << endl;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 512 KB Output is correct
4 Correct 13 ms 1024 KB Output is correct
5 Correct 7 ms 1024 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 167 ms 9404 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 249 ms 10684 KB Output is correct
2 Correct 427 ms 12836 KB Output is correct
3 Execution timed out 5106 ms 148244 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 73 ms 8344 KB Output is correct
3 Correct 149 ms 8796 KB Output is correct
4 Correct 28 ms 2588 KB Output is correct
5 Correct 15 ms 2444 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 512 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 72 ms 5696 KB Output is correct
4 Correct 381 ms 16748 KB Output is correct
5 Correct 200 ms 16700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 161 ms 5276 KB Output is correct
2 Runtime error 4730 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 154 ms 4508 KB Output is correct
2 Correct 1276 ms 67600 KB Output is correct
3 Correct 2467 ms 72720 KB Output is correct
4 Execution timed out 5110 ms 169748 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 214 ms 8912 KB Output is correct
2 Execution timed out 5109 ms 174484 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 216 ms 8668 KB Output is correct
2 Correct 88 ms 4504 KB Output is correct
3 Correct 4123 ms 83644 KB Output is correct
4 Correct 134 ms 10908 KB Output is correct
5 Execution timed out 5029 ms 174148 KB Time limit exceeded