이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "interactive.h"
using namespace std;
int msb(int n) {
if (n == 0) return -1;
int k=0; n/=2;
while (n != 0) ++k, n/=2;
return k;
}
vector<int> guess(int n) {
vector<int> ans(n);
ans[0]=ask(1);
map<int, bool> cnt[15];
for (int i=0; (1<<i)<=n; ++i) {
vector<int> x;
for (int j=2; j<=n; ++j) {
if (j&(1<<i)) x.push_back(j);
}
auto lf=get_pairwise_xor(x);
x.push_back(1);
auto rf=get_pairwise_xor(x);
map<int, int> mp; --mp[0];
for (auto u : lf) --mp[u];
for (auto u : rf) ++mp[u];
for (auto u : mp) {
if (u.second > 0) cnt[i][u.first^ans[0]]=1;
}
}
for (int i=2; i<=n; ++i) {
int m=msb(i);
for (auto u : cnt[m]) {
if (u.second == 0) continue;
bool ok=true;
for (int j=0; (1<<j)<=n; ++j) {
if (i&(1<<j)) {
if (cnt[j][u.first] == 0) ok=false;
} else {
if (cnt[j][u.first] > 0) ok=false;
}
}
if (ok) {
ans[i-1]=u.first;
break;
}
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |