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 in pair<int, int>
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define INF (int)1e17
#define MX (int)3e5+5
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
/*int ask(int i)
{
cout << "What is the value of a[" << i << "]: " << endl;
int ret;
cin >> ret;
return ret;
}
vector<int> get_pairwise_xor(vector<int> pos)
{
cout << "Enter the pairwise xors of following indices: ";
for(int k: pos)
cout << k << " ";
cout << endl;
int t = pos.size();
vector<int> tt;
for(int i = 1; i <= t*t; i++)
{
int ok;
cin >> ok;
tt.pb(ok);
}
return tt;
}*/
vector<int> perm(vector<int> pos)
{
map<int, int> ok;
pos.pb(1);
vector<int> v1 = get_pairwise_xor(pos);
for(int k: v1)
ok[k]++;
pos.pob();
vector<int> v2 = get_pairwise_xor(pos);
for(int k: v2)
{
ok[k]--;
if(ok[k] == 0)
ok.erase(k);
}
ok.erase(0);
for(int k: v1)
{
if(ok.find(k) == ok.end())
continue;
ok[k]/=2;
}
vector<int> v;
for(in kk: ok)
v.pb(kk.f);
return v;
}
vector<int> guess(int n)
{
vector<int> v[8];
int tt = ask(1);
for(int i = 2; i <= n; i++)
{
for(int j = 0; j < 7; j++)
{
if((i>>j)&1ll)
v[j].pb(i);
}
}
map<int, int> position;
position[0] = 1;
for(int j = 0; j < 7; j++)
{
if(v[j].empty())
continue;
vector<int> ok = perm(v[j]);
for(int t: ok)
position[t]+=(1<<j);
}
vector<int> a(n);
for(auto [v, w]: position)
a[w-1] = v^tt;
return a;
}
/*signed main()
{
fast();
int n;
cin >> n;
vector<int> v = guess(n);
cout << "Seq found: " << endl;
for(int t: v)
cout << t << " ";
return 0;
}*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |