This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |