Submission #416453

#TimeUsernameProblemLanguageResultExecution timeMemory
416453KoDThe Collection Game (BOI21_swaps)C++17
100 / 100
9 ms416 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 M = 1 << logn; ord.resize(M, 0); for (int h = 1; h <= logn; ++h) { for (int t = h - 1; t >= 0; --t) { for (int i = 0; i < M; ++i) { const int j = i ^ (1 << t); if (i < j) { if (ord[i] == 0 or ord[j] == 0) { if ((i >> h & 1) ^ (ord[i] == 0)) { std::swap(ord[i], ord[j]); } } else { schedule(ord[i], ord[j]); } } } const auto resp = visit(); int idx = 0; for (int i = 0; i < M; ++i) { const int j = i ^ (1 << t); if (i < j and ord[i] != 0 and ord[j] != 0) { if (!((i >> h & 1) ^ resp[idx++])) { std::swap(ord[i], ord[j]); } } } } } 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...