# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1096816 | KasymK | Xoractive (IZhO19_xoractive) | C++17 | 0 ms | 0 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"
// #include "interactive.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i)
#define wr puts("----------------")
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
vector<int> my;
int ask(int pos){
return my[pos-1];
}
vector<int> get_pairwise_xor(vector<int> &ber){
vector<int> qry;
int n = (int)ber.size();
for(int i = 0; i < n; ++i)
for(int j = 0; j < n; ++j)
qry.pb(my[ber[i]-1]^my[ber[j]-1]);
sort(all(qry));
return qry;
}
vector<int> guess(int n){
vector<int> answer;
for(int ad = 1; ad <= n; ++ad){
vector<int> A;
int ad2;
for(ad2 = ad; ad2 <= ad+3; ++ad2)
A.pb(ad2);
int a = ask(ad);
ad = ad2;
A = get_pairwise_xor(A);
for(int i : A)
printf("%d ", i);
puts("");
wr;
assert((int)A.size() == 16);
vector<int> check, same;
for(int mk = 0; mk < (1<<16); ++mk){
int cnt = __builtin_popcount(mk);
if(cnt != 4)
continue;
for(int i = 0; i < 16; ++i)
if(mk>>i&1)
check.pb(A[i]);
assert((int)check.size() == 4);
vector<int> green, check2 = check;
green.pb(0), green.pb(2), green.pb(4), green.pb(7);
for(int i = 0; i < 4; ++i){
int x = a^check[i];
check[i] = x;
}
if(check2 == green){
puts("men barde." );
for(int i : check)
printf("%d ", i);
puts("");
wr;
}
for(int i = 0; i < 4; ++i)
for(int j = 0; j < 4; ++j)
same.pb(check[i]^check[j]);
assert((int)same.size() == 16);
if(same == A){
for(int i = 0; i < 4; ++i)
answer.pb(check[i]);
break;
}
same.clear(), check.clear();
}
}
return answer;
}
int main(){
freopen("file.txt", "r", stdin);
int n;
scanf("%d", &n);
for(int i = 1; i <= n; ++i){
int x;
scanf("%d", &x);
my.pb(x);
}
vector<int> solve = guess(n);
if(solve == my)
puts("Dogry");
else
puts("Yalnysh");
return 0;
}