#include "interactive.h"
#include <bits/stdc++.h>
using namespace std;
int f;
vector<int> qrs[8], ans;
set<int> res[8], s[405];
set<int> getval(vector<int> v)
{
set<int> t, nw, ans;
if (v.empty()) return ans;
auto tmp=get_pairwise_xor(v);
for (auto x:tmp) t.insert(x);
v.push_back(1);
tmp=get_pairwise_xor(v);
for (auto x:tmp) nw.insert(x);
for (auto x:t) nw.erase(x);
for (auto x:nw) if (x!=0) ans.insert(f^x);
return ans;
}
void solve(int l, int r, int i, int ly, int isl, int rm)
{
if (rm)
{
s[i]=res[ly];
}
else if (isl)
{
for (auto x:s[i/2]) if (res[ly].find(x)!=res[ly].end()) s[i].insert(x);
for (auto x:s[i]) s[i/2].erase(x), res[ly].erase(x);
}
else
{
s[i]=s[i/2];
}
if (l==r)
{
if (!s[i].empty()) ans.push_back(*s[i].begin());
return;
}
int md=(l+r)/2;
solve(l, md, 2*i, ly+1, 1, r==128);
solve(md+1, r, 2*i+1, ly+1, 0, 0);
}
vector<int> guess(int n) {
f=ask(1);
ans.push_back(f);
for (int i=1; i<=7; i++)
{
for (int j=2; j<=128; j++)
{
if (j>n) continue;
if (((j-1)%(1<<(8-i)))<(1<<(7-i))) qrs[i].push_back(j);
}
res[i]=getval(qrs[i]);
//cout<<"res "<<i<<':';
//for (auto x:res[i]) cout<<x<<' ';
//cout<<'\n';
}
solve(1, 128, 1, 0, 0, 0);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Incorrect |
1 ms |
344 KB |
Output is not correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
600 KB |
Output is correct |
2 |
Correct |
5 ms |
600 KB |
Output is correct |
3 |
Incorrect |
3 ms |
344 KB |
Output is not correct |
4 |
Halted |
0 ms |
0 KB |
- |