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;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
// #pragma GCC optimize("Ofast,unroll-loops,fast-math")
// #pragma GCC target("popcnt,sse3,avx")
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
#define sz size()
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define pb push_back
const int mod = ll(1e9)+7; //(b + (a%b)) % b (to mod -1%(10^9+7) correctly in c++ its -1 but its suppose to be 10^9+6
const ll MOD = 998244353; // (a%mod)*(binpow(b,mod-2,mod) = (a/b)%mod
const int N = ll(5e5)+100;
const int M = ll(2e5) + 100;
const long long inf = 5e18;
//const long double eps = 1e-15L;
int ask(int position);
std::vector<int> get_pairwise_xor(std::vector<int> positions);
vector<int> guess(int n) {
int a[n + 1];
a[1] = ask(1);
map<int, int> pos;
for(int i = 0; i < 7; i ++) {
vector<int> v;
for(int j = 2; j <= n; j ++) {
if(j & (1 << i)) v.pb(j);
}
if(v.empty()) break;
vector<int> get = get_pairwise_xor(v);
v.pb(1);
vector<int> get1 = get_pairwise_xor(v);
map<int, int> cnt;
for(auto x : get1) cnt[x] ++;
for(auto x : get) cnt[x] --;
for(auto x : cnt) {
if(x.ff && x.ss) pos[(x.ff ^ a[1])] |= (1 << i);
}
}
for(auto x : pos) a[x.ss] = x.ff;
vector<int> res;
for(int i = 1; i <= n; i ++) {
res.pb(a[i]);
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |