#include "interactive.h"
// #include "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
set<int> G(vector<int> vec, int n, int a1)
{
vector<int> v1 = get_pairwise_xor(vec);
vec.push_back(a1);
vector<int> v2 = get_pairwise_xor(vec);
multiset<int> s1;
for(auto i : v2)
s1.insert(i);
for(auto i : v1)
s1.erase(s1.find(i));
set<int> res;
for(auto i : s1)
res.insert(i);
res.erase(res.begin());
return res;
}
struct Node
{
int l, r;
set<int> v;
};
vector<int> guess(int N)
{
int n = N;
int a1 = ask(1);
vector<Node> vec;
vector<int> V;
for(int i = 2; i <= n; i++)
V.push_back(i);
set<int> ssss = G(V, n, a1);
vec.push_back({2, n, ssss});
// for(auto i : vec[0].v)
// cout << i << ' ';
// exit(0);
while(1)
{
V.clear();
for(auto i : vec)
{
if(i.l == i.r)
continue;
int m = (i.l + i.r) / 2;
for(int j = i.l; j <= m; j++)
V.push_back(j);
}
if(V.size() == 0)
break;
set<int> S = G(V, n, a1);
vector<Node> v2;
for(auto i : vec)
{
if(i.l == i.r)
{
v2.push_back(i);
continue;
}
int m = (i.l + i.r) / 2;
set<int> s1, s2 = i.v;
for(auto j : i.v)
{
if(S.find(j) == S.end())
continue;
s2.erase(j);
s1.insert(j);
}
v2.push_back({i.l, m, s1});
v2.push_back({m + 1, i.r, s2});
}
vec = v2;
}
vector<int> res(n);
res[0] = a1;
for(auto i : vec)
res[i.l - 1] = *i.v.begin();
// for(auto i : res)
// cout << i << ' ';
// cout << "\n";
// exit(0);
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |