This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "interactive.h"
using namespace std;
#ifdef MIKU
string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m";
#define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x)
void dout() { cout << dbrs << endl; }
template <typename T, typename ...U>
void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); }
#else
#define debug(...) 39
#endif
#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
using ll = long long;
typedef pair<int, int> pii;
namespace {
const int MXN = 105;
int n;
vector<int> a;
vector<int> XOR(vector<int> v) {
for (auto &i : v) i++;
return get_pairwise_xor(v);
}
multiset<int> GET_MS(vector<int> v) {
multiset<int> MS;
set<int> S;
v.push_back(0);
vector<int> w = XOR(v);
for (auto &i : w) MS.insert(i);
v.pop_back();
w = XOR(v);
for (auto &i : w) MS.erase(MS.find(i));
MS.erase(MS.begin());
for (auto i : MS) S.insert(i);
MS.clear();
for (auto i : S) MS.insert(i);
return MS;
}
vector<int> solve() {
multiset<int> MS[7];
set<int> cand;
a.resize(n);
a[0] = ask(1);
int h = __lg(n - 1) + 1;
FOR(w, 0, h) {
vector<int> v;
FOR(i, 1, n) if (i & (1 << w)) v.push_back(i);
MS[w] = GET_MS(v);
for (auto j : MS[w]) cand.insert(j);
}
auto query = [&](int x) -> int {
int id = 0;
FOR(w, 0, h) {
if (MS[w].find(x) != MS[w].end()) id |= (1 << w);
}
return id;
};
for (auto i : cand) a[query(i)] = i;
FOR(i, 1, n) a[i] ^= a[0];
return a;
}
}
vector<int> guess(int N) {
::n = N;
return solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |