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 "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define prc(n) fixed << setprecision(n)
#define fastios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi acos(-1);
const int inf = 1e9+7;
const int N = 105;
vector<int> guess(int n){
int fir = ask(1);
vector<multiset<int>>a(10);
for(int i=0;i<8;i++){
vector<int>tmp;
vector<int>ans, ans1;
for(int j=2;j<=n;j++) if((1 << i) & j){
tmp.pb(j);
}
if(tmp.empty()) continue;
ans = get_pairwise_xor(tmp);
tmp.pb(1);
ans1 = get_pairwise_xor(tmp);
multiset<int>ss;
for(int j=0; j<sz(ans1); j++) ss.insert(ans1[j]);
for(int j=0; j<sz(ans); j++) ss.erase(ss.find(ans[j]));
for(auto x = ss.begin(); x != ss.end(); x++){
int xx = *x;
if(xx == 0) continue;
xx ^= fir;
a[i].insert(xx);
}
}
vector<int>ans(n);
ans[0] = fir;
for(int i=1;i<n;i++){
int j = 0, l = 0;
while(sz(a[j]) == 0 && j < 10) j++;
if(j == 10) break;
int cur = *a[j].begin();
int in = 0;
for(l = 0;l<7;l++){
if(a[l].find(cur) != a[l].end()){
a[l].erase(cur);
in += (1<<l);
}
}
ans[in -1] = cur;
}
//for(int i=0;i<n;i++) cout<<ans[i]<<" ";
//cout<<endl;
return ans;
}
/*
20
20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |