# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
424851 | doowey | Xoractive (IZhO19_xoractive) | C++14 | 12 ms | 540 KiB |
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 "interactive.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
const int B = 7;
vector<int> has[B];
vector<int> nob[B];
vector<int> intersect(vector<int> A, vector<int> B){
int jj = 0;
vector<int> res;
for(auto x : A){
while(jj < B.size() && B[jj] < x){
jj ++ ;
}
if(jj < B.size() && B[jj] == x){
res.push_back(x);
}
}
return res;
}
vector<int> guess(int n) {
int base = ask(1);
for(int lg = 0 ; lg < B; lg ++ ){
vector<int> res;
res.push_back(1);
for(int i = 2; i <= n; i ++ ){
if((i & (1 << lg)))
res.push_back(i);
}
vector<int> chk, ff;
chk = get_pairwise_xor(res);
for(auto x : chk){
if(x != 0)
ff.push_back(x);
}
has[lg] = ff;
vector<int> nah;
nah.push_back(1);
for(int i = 2; i <= n; i ++ ){
if((i & (1 << lg))){
continue;
}
nah.push_back(i);
}
chk = get_pairwise_xor(nah);
ff.clear();
for(auto x : chk){
if(x != 0)
ff.push_back(x);
}
nob[lg] = ff;
}
vector<int> outp = {base};
vector<int> rr;
vector<int> cur;
for(int id = 2; id <= n; id ++ ){
rr.clear();
for(int lg = 0; lg < B; lg ++ ){
if((id & (1 << lg))){
cur = has[lg];
}
else{
cur = nob[lg];
}
if(rr.empty()) rr = cur;
else rr = intersect(rr, cur);
}
outp.push_back((rr[0] ^ base));
}
return outp;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |