Submission #416426

#TimeUsernameProblemLanguageResultExecution timeMemory
416426KoDThe Collection Game (BOI21_swaps)C++17
100 / 100
8 ms396 KiB
#include <bits/stdc++.h> #include "swaps.h" template <class T> using Vec = std::vector<T>; void solve(int N, int V) { Vec<int> ord(N); std::iota(ord.begin(), ord.end(), 1); int logn = 0; while ((1 << logn) < N) { logn += 1; } const int N2 = 1 << logn; ord.resize(N2, 0); for (int h = 1; h <= logn; ++h) { for (int t = h - 1; t >= 0; --t) { const int bit = (1 << t); for (int i = 0; i < N2; ++i) { if (!(i >> t & 1) and ord[i] != 0 and ord[i + bit] != 0) { schedule(ord[i], ord[i + bit]); } } int idx = 0; const auto resp = visit(); for (int i = 0; i < N2; ++i) { if (!(i >> t & 1)) { const auto x = (ord[i] == 0 ? 0 : (ord[i + bit] == 0 ? 1 : resp[idx++])); if (!((i >> h & 1) ^ x)) { std::swap(ord[i], ord[i + bit]); } } } } } ord.resize(N); answer(ord); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...