Submission #416668

#TimeUsernameProblemLanguageResultExecution timeMemory
416668noshi91The Collection Game (BOI21_swaps)C++17
0 / 100
1 ms200 KiB
#include <cstdint> #include <vector> namespace bitonic_sorter_impl { using u32 = std::uint32_t; std::vector<std::vector<std::pair<u32, u32>>> bitonic_sorter(const u32 n) { std::vector<std::vector<std::pair<u32, u32>>> ret; for (u32 w = 1; w < n; w *= 2) { for (u32 s = w; s != 0; s /= 2) { ret.push_back({}); bool rev = false; for (u32 t = 0; t < n; t += 2 * w) { for (u32 k = 0; k != 2 * w; k += 2 * s) { for (u32 i = 0; i != s; i += 1) { u32 a = t + k + i; u32 b = t + k + i + s; if (b < n) { if (rev) { ret.back().push_back({ b, a }); } else { ret.back().push_back({ a, b }); } } } } rev = !rev; } } } return ret; } } // namespace bitonic_sorter_impl using bitonic_sorter_impl::bitonic_sorter; #include <algorithm> #include <numeric> #include <utility> #include <swaps.h> void solve(int N, int V) { std::vector<int> a(N); std::iota(a.begin(), a.end(), 0); for (const auto &v : bitonic_sorter(N)) { for (const auto &[a, b] : v) { schedule(a + 1, b + 1); } const auto res = visit(); for (int i = 0; i != v.size(); i += 1) { if (res[i]) { std::swap(a[v[i].first], a[v[i].second]); } } } std::reverse(a.begin(), a.end()); for (auto& e : a) { e += 1; } answer(a); }

Compilation message (stderr)

swaps.cpp: In function 'void solve(int, int)':
swaps.cpp:54:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<unsigned int, unsigned int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     for (int i = 0; i != v.size(); i += 1) {
      |                     ~~^~~~~~~~~~~
#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...