Submission #381085

#TimeUsernameProblemLanguageResultExecution timeMemory
381085mohamedsobhi777Xoractive (IZhO19_xoractive)C++14
88 / 100
11 ms1020 KiB
#include <bits/stdc++.h> #include "interactive.h" using namespace std; int a0; struct state { int l, r; vector<int> lhs, rhs, mems; state(int l, int r) : l(l), r(r) {} }; vector<int> get_all(vector<int> v) { vector<int> ret = get_pairwise_xor(v); for (auto u : v) assert(u != 1); v.push_back(1); vector<int> ret2 = get_pairwise_xor(v); sort(ret.begin(), ret.end()); sort(ret2.begin(), ret2.end()); multiset<int> mu; vector<int> ret3; for (auto u : ret2) mu.insert(u); for (auto u : ret) mu.erase(mu.find(u)); for (auto u : mu) if (u) ret3.push_back(u ^ a0); sort(ret3.begin(), ret3.end()); ret3.erase(unique(ret3.begin(), ret3.end()), ret3.end()); return ret3; } vector<int> guess(int n) { vector<int> ans; a0 = ask(1); ans.resize(n - 1); iota(ans.begin(), ans.end(), 2); ans = get_all(ans); vector<state> stt; stt.push_back(state(1, n)); ans.push_back(a0); stt.back().mems = ans; while (stt.size()) { bool flag = 1; vector<int> lhs, rhs; vector<state> stt2; for (auto u : stt) { if (u.l != u.r) flag = 0; if (u.l == u.r) { stt2.push_back(u); continue; } int mid = (u.l + u.r) >> 1; for (int j = mid + 1; j <= u.r; ++j) rhs.push_back(j); stt2.push_back(state(u.l, mid)); stt2.push_back(state(mid + 1, u.r)); } rhs = get_all(rhs); sort(rhs.begin(), rhs.end()); auto isR = [&](int x) -> bool { if (binary_search(rhs.begin(), rhs.end(), x)) return 1; return 0; }; int j = 0; for (int i = 0; i < stt.size(); ++i) { if (stt[i].l == stt[i].r) { ++j; } else { for (auto u : stt[i].mems) { if (isR(u)) stt2[j + 1].mems.push_back(u); else stt2[j].mems.push_back(u); } j += 2; } } stt = stt2; if (stt.size() == n) break; } ans.clear(); for (auto u : stt) ans.push_back(u.mems.back()); return ans; }

Compilation message (stderr)

Xoractive.cpp: In function 'std::vector<int> guess(int)':
Xoractive.cpp:80:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<state>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |               for (int i = 0; i < stt.size(); ++i)
      |                               ~~^~~~~~~~~~~~
Xoractive.cpp:99:30: warning: comparison of integer expressions of different signedness: 'std::vector<state>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   99 |               if (stt.size() == n)
      |                   ~~~~~~~~~~~^~~~
Xoractive.cpp:53:20: warning: variable 'flag' set but not used [-Wunused-but-set-variable]
   53 |               bool flag = 1;
      |                    ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...