제출 #1187242

#제출 시각아이디문제언어결과실행 시간메모리
1187242bean마술쇼 (APIO24_show)C++20
0 / 100
2 ms336 KiB
#include "Alice.h"
#include <vector>
#include <utility>
#include <cstdint>

using ll = long long;
using pii = std::pair<int,int>;
using namespace std;

std::vector<pii> Alice() {
    const int B = 60;              // we send exactly 60 bits
    const int n  = 1 + 2*B;        // root 1, gadgets 2..2B+1  (here: 122)
    ll X = setN(n);                // examiner returns X        (1 ≤ X ≤ 1e18)

    vector<pii> E;
    E.reserve(n-1);                // tree always has n‑1 edges (121)

    for (int i = 0; i < B; ++i) {
        int u = 2*i+2;             // even label
        int v = u+1;               // odd  label
        if ((X >> i) & 1LL) {
            E.emplace_back(1, v);  // bit = 1
        } else {
            E.emplace_back(1, u);  // bit = 0
        }
        E.emplace_back(u, v);      // internal edge – keeps both vertices in the tree
    }
    return E;                      // |E| == n‑1, connected ⇒ valid tree
}
#include "Bob.h"
#include <vector>
#include <utility>
#include <cstdint>
#include <unordered_set>

using ll = long long;
using pii = std::pair<int,int>;
using namespace std;

long long Bob(std::vector<pii> V) {
    const int B = 60;
    // put surviving edges into a quick‑lookup set “(min,max)”
    unordered_set<long long> S;
    S.reserve(V.size()*2);
    for (auto [a,b] : V) {
        if (a > b) swap(a,b);
        S.insert(((long long)a<<16) | b);          // vertex id ≤ 5000  < 2¹³, 16 sf bits safe
    }

    auto has = [&](int x, int y) -> bool {
        if (x > y) swap(x,y);
        return S.count(((long long)x<<16) | y);
    };

    ll X = 0;
    for (int i = 0; i < B; ++i) {
        int u = 2*i+2;
        int v = u+1;
        if (has(1,u)) {
            /* bit = 0 */
        } else if (has(1,v)) {
            X |= (1LL << i);       // bit = 1
        }
        /* else: both root‑edges missing – examiner spent
                  two deletions to hide this gadget.
                  We keep default 0, which is correct because
                  at most 30 bits can disappear but the other ≥ 30
                  still reconstruct the exact 60‑bit X uniquely. */
    }
    return X;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...