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;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }
using ll=int;
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>;
long long LLINF = 1e18;
int INF = 1e9+1e6;
#define MAXN (200006)
map<ll,ll> mp;
vector<int> guess(int n) {
vector<int> ans(n+1);
ans[1]=ask(1), ans[2]=ask(2);
vector<vector<ll>> v[2];
auto fix=[&](vector<ll> x,vector<ll> y){
vector<ll> z;
reverse(all(x)), reverse(all(y));
while(x.size()) {
if(y.empty()) { z.eb(x.back()); x.pop_back(); continue; }
if(x.back()==y.back()) x.pop_back(), y.pop_back();
else z.eb(x.back()), x.pop_back();
}
return z;
};
FOR(i,0,6) {
vector<ll> zero, one, tmp;
FOR(j,3,n) {
if(1<<i&j) one.eb(j);
else zero.eb(j);
}
if(zero.size()){
tmp=get_pairwise_xor(zero);
zero.eb(1);
zero=get_pairwise_xor(zero);
zero=fix(zero, tmp);
zero.resize(unique(all(zero))-zero.begin());
if(zero[0]==0) zero.erase(zero.begin());
for(auto&i:zero) i^=ans[1];
}
if(one.size()) {
tmp=get_pairwise_xor(one);
one.eb(2);
one=get_pairwise_xor(one);
one=fix(one, tmp);
one.resize(unique(all(one))-one.begin());
if(one[0]==0) one.erase(one.begin());
for(auto&i:one) i^=ans[2];
}
v[0].eb(zero), v[1].eb(one);
}
FOR(j,3,n) {
mp.clear();
for(auto k:v[0]) for(auto j:k) ++ mp[j];
for(auto k:v[1]) for(auto j:k) ++ mp[j];
FOR(i,0,6) if(1<<i&j) {
for(auto j:v[1][i]) -- mp[j];
} else {
for(auto j:v[0][i]) -- mp[j];
}
for(auto i:mp) if(i.s==0) ans[j]=i.f;
}
ans.erase(ans.begin());
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |