Submission #399103

#TimeUsernameProblemLanguageResultExecution timeMemory
399103iulia13Xoractive (IZhO19_xoractive)C++14
100 / 100
6 ms456 KiB
#include <iostream> #include <map> #include <vector> #include <algorithm> #include "interactive.h" using namespace std; map <int, int> mp;/* vector <int> a; int n; int ask(int position) { return a[position - 1]; } vector<int> get_pairwise_xor(vector<int> positions) { vector<int> pairwise_xor; for (int i = 0; i < positions.size(); i++) { for (int j = 0; j < positions.size(); j++) { pairwise_xor.push_back(a[positions[i] - 1] ^ a[positions[j] - 1]); } } sort(pairwise_xor.begin(), pairwise_xor.end()); return pairwise_xor; }*/ vector <int> guess(int n) { vector <int> v; v.resize(n); v[0] = ask(1); for (int i = 0; (1 << i) <= n; i++) { vector <int> poz; vector <int> poz1; vector <int> poz2; int cnt = 0, n1, n2; for (int j = 2; j <= n; j++) if (j & (1 << i)) poz.push_back(j), cnt++; poz1 = get_pairwise_xor(poz); poz1.resize(cnt * cnt); n1 = cnt * cnt; poz.push_back(1); poz2 = get_pairwise_xor(poz); n2 = (cnt + 1) * (cnt + 1); poz2.resize(n2); map <int, int> mpp; for (auto x : poz2) mpp[x]++; for (auto x : poz1) mpp[x]--; for (auto x : mpp) if (x.second) mp[x.first ^v[0]] |= (1 << i); } for (auto x : mp) v[x.second - 1] = x.first; return v; }/* int main() { cin >> n; for (int i = 1; i <= n; i++) { int x; cin >> x; a.push_back(x); } a.resize(n); vector<int> participant_solution = guess(n); participant_solution.resize(n); for (int i = 0; i < n; i++) cout << participant_solution[i] << " "; return 0; }*/

Compilation message (stderr)

Xoractive.cpp: In function 'std::vector<int> guess(int)':
Xoractive.cpp:36:22: warning: variable 'n1' set but not used [-Wunused-but-set-variable]
   36 |         int cnt = 0, n1, n2;
      |                      ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...