Submission #346685

#TimeUsernameProblemLanguageResultExecution timeMemory
346685milleniumEeeeXoractive (IZhO19_xoractive)C++17
100 / 100
6 ms492 KiB
#include "interactive.h" //#include "grader.cpp" #include <bits/stdc++.h> #define all(s) s.begin(), s.end() #define szof(s) (int)s.size() using namespace std; int x; vector <int> get_numbers(vector <int> pos) { // 2 queries vector <int> vec1, vec2; vec1.push_back(1); for (int el : pos) { vec1.push_back(el); } for (int el : pos) { vec2.push_back(el); } map <int, int> mp; vector <int> pairwise = get_pairwise_xor(vec1); for (int el : pairwise) { mp[el]++; } pairwise = get_pairwise_xor(vec2); for (int el : pairwise) { mp[el]--; } mp[0]--; vector <int> numbers; for (auto &el : mp) { el.second /= 2; for (int i = 1; i <= el.second; i++) { numbers.push_back((x ^ el.first)); } } sort(all(numbers)); return numbers; } bool exist(vector <int> &vec, int x) { return binary_search(all(vec), x); } vector<int> guess(int n) { vector <int> ans(n); x = ask(1); ans[0] = x; if (n == 1) { return ans; } vector <int> arr; for (int i = 2; i <= n; i++) { arr.push_back(i); } map <int, int> pos; for (int i = 0; i <= 7; i++) { vector <int> on; for (int mask = 2; mask <= n; mask++) { if (mask & (1 << i)) { on.push_back(mask); } } if (on.empty()) { continue; } vector <int> vec = get_numbers(on); for (int num : vec) { pos[num] += (1 << i); } } for (auto el : pos) { ans[el.second - 1] = el.first; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...