#include <bits/stdc++.h>
#include "interactive.h"
using namespace std;
#define threesum cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false)
#define all(a) a.begin(), a.end()
#define F first
#define S second
//#define int long long
#define double long double
#define pii pair<int, int>
#define ppp pair<int, pii>
#define dout cout << fixed << setprecision(15)
#define mid ((l + r) / 2)
#define lc (2 * id)
#define rc (lc + 1)
//const int maxn = 3e5 + 10, maxm = 1e3 + 10, oo = 1e18 + 10, lg = 8, sq = 350, mod = 1e9 + 7;
vector<int> guess(int n){
vector<int> a(n);
a[0] = ask(1);
map<int, int> mp;
for (int b = 0; b < 7;b++){
vector<int> u, v, f;
for (int i = 2; i <= n; i++)
if(i & (1ll << b))
v.push_back(i);
if(!v.size())
continue;
u = get_pairwise_xor(v);
v.push_back(1);
f = get_pairwise_xor(v);
multiset<int> s;
for(auto i : f)
s.insert(i);
for(auto i : u)
s.erase(s.find(i));
for(auto j : s)
mp[j ^ a[1]] |= (1ll << b);
}
vector<pii> vp;
for(auto [x, msk] : mp)
vp.push_back({msk, x});
set<int> used;
used.insert(a[1]);
sort(all(vp));
reverse(all(vp));
for(auto [msk, x] : vp)
if(used.find(x) == used.end()){
a[msk - 1] = x;
used.insert(x);
}
return a;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |