# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
527840 | definitelynotmee | Xoractive (IZhO19_xoractive) | C++17 | 2 ms | 328 KiB |
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<bits/stdc++.h>
#define mp make_pair
#define mt make_tuple
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
using namespace std;
template <typename T>
using matrix = vector<vector<T>>;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INFL = (1LL<<62)-1;
const int INF = (1<<30)-1;
const double EPS = 1e-7;
const int MOD = 1e9 + 7;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
const int MAXN = 1e6+1;
#include "interactive.h"
/*vector<int> arr;
int ask(int i){
cout << "ask " << i << endl;
int in;
cin >> in;
return in;
}
vector<int> get_pairwise_xor(vector<int> q){
/*cout << "get_pairwise_xor ";
for(int i : q)
cout << i << ' ';
cout << endl;
vector<int> ret;
for(int i = 0; i < q.size(); i++){
for(int j = i; j < q.size(); j++){
ret.push_back(arr[q[i]-1]^arr[q[j]-1]);
}
}
sort(all(ret));
return ret;
}*/
int ask(int i);
vector<int> get_pairwise_xor(vector<int> q);
vector<int> guess(int n) {
int last = ask(n);
auto getset =[&](vector<int> q)->vector<int>{
cout << "getset ";
for(int i : q)
cout << i << ' ';
cout << '\n';
q.push_back(n);
vector<int> tot = get_pairwise_xor(q);
q.pop_back();
vector<int> totminus = get_pairwise_xor(q);
vector<int> v(q.size());
cout << "tot: ";
for(int i : tot)
cout << i << ' ';
cout << '\n';
cout << "totminus: ";
for(int i : totminus)
cout << i << ' ';
cout << endl;
int p1 = 0, p2 = 0;
int ptr = 0;
while(p1 < tot.size()){
cout << "p1 = " << p1 << "(" << tot[p1] <<"), p2 = " << p2 << "(" << totminus[p2] << ");\n";
if(p2 == totminus.size() || totminus[p2] != tot[p1]){
if(tot[p1] != 0){
v[ptr] = tot[p1]^last;
ptr++;
p1++;
}
} else p2++;
p1++;
}
cout << "-> ";
for(int i : v)
cout << i << ' ';
cout << endl;
assert(ptr == q.size());
/*cout << "getset ";
for(int i : q)
cout << i << ' ';
cout << "\n-> ";
for(int i : v)
cout << i << ' ';
cout << endl;*/
return v;
};
cout << 1 << endl;
vector<int> q(n-1);
iota(all(q),1);
matrix<int> group = {getset(q)};
cout << 2 << endl;
int timer = 3;
while(group.size() < n-1){
cout << timer++ << endl;
matrix<int> newgroup;
vector<int> q;
int ct = 1;
for(vector<int>& i : group){
for(int j = 0; j < (i.size()+1)/2; j++)
q.push_back(ct), ct++;
ct+=i.size()-(i.size()+1)/2;
}
vector<int> r = getset(q);
set<int> s(all(r));
for(vector<int>& i : group){
vector<int> g1, g2;
for(int j : i){
if(s.count(j))
g1.push_back(j);
else g2.push_back(j);
}
if(g1.size())
newgroup.push_back(g1);
if(g2.size())
newgroup.push_back(g2);
}
swap(group,newgroup);
}
vector<int> resp;
for(int i = 0 ; i < group.size(); i++){
/*cout << i << ":\n";
for(int j : group[i])
cout << j << ' ';
cout << '\n';*/
assert(group[i].size());
resp.push_back(group[i].back());
}
resp.push_back(last);
for(int i : resp)
cout << i << ' ';
cout << endl;
return resp;
}
/*
int main(){
int n;
cin >> n;
arr = vector<int>(n);
for(int i = 0; i < n; i++){
cin >> arr[i];
}
vector<int> resp = guess(n);
cout << "! ";
for(int i : resp)
cout << i << ' ';
cout << '\n';
}
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |