이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#include "interactive.h"
// ask(i) := returns value at i
// get_pairwise_xor(vec) := returns a set of pairwise xor's
map<int, int> loc;
vector<int> guess(int n){
int lst = ask(n);
for(int bt = 0; bt < 7; bt++){
vector<int> vec;
for(int i = 1; i <= n - 1; i++)
if(i & (1 << bt)) vec.push_back(i);
vector<int> st, fn;
{
if(vec.empty()) st = {};
else st = get_pairwise_xor(vec);
}
{
vec.push_back(n);
fn = get_pairwise_xor(vec);
}
vector<int> vals;
int a = 0, b = 0;
for(; a < (int) st.size(); a++, b++)
while(b < (int) fn.size() && fn[b] != st[a]) vals.push_back(fn[b++]);
while(b < (int) fn.size()) vals.push_back(fn[b++]);
for(int j = 1; j < (int) vals.size(); j += 2)
loc[vals[j] ^ lst] ^= 1 << bt;
}
vector<int> ans;
ans.resize(n, 0);
for(auto x : loc) ans[x.second - 1] = x.first;
ans[n - 1] = lst;
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |