이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "interactive.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define all(x) begin(x), end(x)
using namespace std;
vector<int> guess(int n) {
vector <int> ans (n);
map<int, int> pos;
ans[0] = ask(1);
pos[ans[0]]=1;
for(int i = 0; i < 7; i++){
map<int, int> cont;
vector<int> A, B = {1};
for(int j = 2; j <= n; j++){
if(j&(1<<i)){
A.pb(j);
B.pb(j);
}
}
if(A.empty()) continue;
auto ans_A = get_pairwise_xor(A);
auto ans_B = get_pairwise_xor(B);
sort(all(ans_A));
sort(all(ans_B));
for(auto x: ans_B){
int cnt_A = upper_bound(all(ans_A), x) - lower_bound(all(ans_A), x);
int cnt_B = upper_bound(all(ans_B), x) - lower_bound(all(ans_B), x);
if(cnt_B > cnt_A and x != ans[1]){
pos[x^ans[0]] |= (1<<i);
}
}
}
for(auto x: pos) ans[x.s-1] = x.f;
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |