Submission #990874

#TimeUsernameProblemLanguageResultExecution timeMemory
990874ToniBXoractive (IZhO19_xoractive)C++17
100 / 100
3 ms512 KiB
#include <bits/stdc++.h> #include "interactive.h" using namespace std; vector<int> ans; void reduce(vector<int>& v, int sz) { vector<int> cur = {}; sort(v.begin(), v.end()); for (int i = sz; i < (int)v.size(); i += 2) cur.push_back(v[i]); swap(cur, v); } vector<int> get_values(vector<int> pos) { vector<int> with = pos; with.push_back(1); sort(with.begin(), with.end()); vector<int> xr_with = get_pairwise_xor(with); vector<int> xr_without = get_pairwise_xor(pos); reduce(xr_with, with.size()); reduce(xr_without, pos.size()); vector<int> vals = {}; for (int val : xr_without) { for (int i = 0; i < (int)xr_with.size(); ++i) { if (xr_with[i] == val) { xr_with.erase(xr_with.begin() + i); break; } } } for (int val : xr_with) { vals.push_back(val ^ ans[0]); } return vals; } vector<int> guess(int n) { map<int, int> mp; ans.resize(n); ans[0] = ask(1); for (int i = 0; i < 7; ++i) { vector<int> cur; for (int j = 2; j <= n; ++j) { if (j & 1 << i) cur.push_back(j); } if (cur.empty()) continue; vector<int> v = get_values(cur); for (int val : v) { mp[val] += 1 << i; } } for (pair<int, int> p : mp) { ans[p.second - 1] = p.first; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...