Submission #722197

#TimeUsernameProblemLanguageResultExecution timeMemory
722197tvladm2009Xoractive (IZhO19_xoractive)C++17
100 / 100
6 ms392 KiB
#include <bits/stdc++.h>
#include "interactive.h"

using namespace std;

typedef long long ll;

vector <int> guess(int N) {
    vector <int> answer(N);
    map <int, int> mp;

    int last = ask(N);
    answer[N - 1] = last;

    for (int bit = 0; bit < 7; bit++) {
        vector <int> v;
        for (int i = 1; i < N; i++) {
            if (i & (1 << bit)) {
                v.push_back(i);
            }
        }
        vector <int> resp1, resp2;
        if (v.empty() == true) {
            resp1.clear();
        } else {
            resp1 = get_pairwise_xor(v);
        }
        v.push_back(N);
        resp2 = get_pairwise_xor(v);
        map <int, int> cnt;
        for (auto it : resp1) {
            cnt[it]--;
        }
        for (auto it : resp2) {
            cnt[it]++;
        }
        for (auto it : cnt) {
            if (it.first > 0 && it.second > 0) {
                mp[it.first ^ last] |= (1 << bit);
            }
        }
    }
    for (auto it : mp) {
        answer[it.second - 1] = it.first;
    }
    return answer;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...