Submission #202473

#TimeUsernameProblemLanguageResultExecution timeMemory
202473klungsXoractive (IZhO19_xoractive)C++14
88 / 100
14 ms1016 KiB
#include "interactive.h" #include <bits/stdc++.h> using namespace std; vector <int> ans; vector<int> contains(vector<int> q) { if (q.size() == 0) return {}; vector<int> qf = q; qf.push_back(1); auto res1 = get_pairwise_xor(qf); auto res2 = get_pairwise_xor(q); multiset<int> gg; for (auto x : res1) gg.insert(x); for (auto x : res2) gg.erase(gg.find(x)); gg.erase(gg.find(0)); vector<int> res; map<int, int> cnt_gg; for (auto x : gg) { cnt_gg[x]++; } for (auto x : cnt_gg) { for (int i = 0; i < x.second; i+= 2) { res.push_back(x.first ^ ans[1]); } } // cerr << res.size() << " " << q.size() << endl; assert(res.size() == q.size()); return res; } vector<int> guess(int n) { ans.resize(n + 1); ans[1] = ask(1); vector<int> questions[7], answers[7]; vector<int> question_all(n - 1); iota(question_all.begin(), question_all.end(), 2); vector<int> all = contains(question_all); map<int, int> id; for (auto i : all) { id[i] = 0; } for (int i = 2; i <= n; i++) { for (int j = 0; j < 7; j++) if ((1 << j) & i) { questions[j].push_back(i); } } for (int j = 0; j < 7; j++) { answers[j] = contains(questions[j]); for (int x : answers[j]) { id[x] ^= (1 << j); } } for (auto x : id) { ans[x.second] = x.first; } vector<int> fix_ans(ans.begin() + 1, ans.end()); return fix_ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...