Submission #155839

#TimeUsernameProblemLanguageResultExecution timeMemory
155839qkxwsmXoractive (IZhO19_xoractive)C++14
100 / 100
20 ms552 KiB
#include "interactive.h" #include <bits/stdc++.h> using namespace std; template<class T, class U> void ckmin(T &a, U b) { if (a > b) a = b; } template<class T, class U> void ckmax(T &a, U b) { if (a < b) a = b; } #define MP make_pair #define PB push_back #define LB lower_bound #define UB upper_bound #define fi first #define se second #define FOR(i, a, b) for (auto i = (a); i < (b); i++) #define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--) #define SZ(x) ((int) ((x).size())) #define ALL(x) (x).begin(), (x).end() typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vpi; typedef vector<pll> vpl; int N; vi ans; set<int> stor[8]; set<int> cand; int qry(int x) { return ask(x + 1); } map<int, int> qry1(vi v) { for (int &x : v) x++; // for (int x : v) // { // cerr << "MOO " << x << endl; // } map<int, int> mp; if (v.empty()) return mp; vi res = get_pairwise_xor(v); for (int x : res) { mp[x]++; } mp[0] -= SZ(v); for (auto it = mp.begin(); it != mp.end(); it++) { (it -> se) /= 2; } return mp; } vi guess(int n) { N = n; ans.resize(N); ans[0] = qry(0); //which guys have this bit as 1? // cerr << "OK\n"; FOR(i, 0, 7) { vi guys; FOR(j, 1, N) { if (j & (1 << i)) { guys.PB(j); } } auto wo = qry1(guys); guys.PB(0); auto wi = qry1(guys); for (auto p : wo) { wi[p.fi] -= p.se; } for (auto p : wi) { if (p.se > 0) { stor[i].insert(p.fi ^ ans[0]); } } for (int x : stor[i]) { cand.insert(x); } } // cerr << "HEY\n"; // for (int x : cand) // { // cerr << "CAND " << x << endl; // } FOR(i, 1, N) { set<int> cur = cand; FOR(j, 0, 7) { for (auto it = cur.begin(); it != cur.end(); ) { bool hasbit = (i & (1 << j)); bool hasnum = (stor[j].find(*it) != stor[j].end()); if (hasbit ^ hasnum) { it = cur.erase(it); } else { it++; } } } ans[i] = *cur.begin(); } //S vs aS return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...