제출 #169608

#제출 시각아이디문제언어결과실행 시간메모리
169608apostoldaniel854Xoractive (IZhO19_xoractive)C++14
100 / 100
6 ms504 KiB
#include <bits/stdc++.h>
#include <interactive.h>
using namespace std;

typedef long long ll;
#define pb push_back

vector <int> guess (int n) {
    if (n <= 6) {
        vector <int> ans;
        for (int i = 1; i <= n; i++)
            ans.pb (ask (i));
        return ans;
    }
    int lst = ask (n);
    map <int, int> nr;
    for (int bit = 0; bit < 7; bit++) {
        vector <int> q;
        for (int i = 1; i < n; i++) {
            if (i & (1 << bit))
                q.pb (i);
        }

        auto x = get_pairwise_xor (q);
        q.pb (n);
        auto y = get_pairwise_xor (q);
        map <int, int> mp;
        for (auto it : x)
            mp[it]--;
        for (auto it : y)
            mp[it]++;
        for (auto it : mp)
            if (it.first && it.second)
                nr[it.first ^ lst] |= (1 << bit);
    }
    vector <int> ans (n);
    for (auto it : nr)
        ans[it.second - 1] = it.first;
    ans[n - 1] = lst;
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...