Submission #429889

#TimeUsernameProblemLanguageResultExecution timeMemory
429889dolphingarlicThe Collection Game (BOI21_swaps)C++14
100 / 100
8 ms416 KiB
#include "swaps.h" #include <numeric> #include <algorithm> void solve(int N, int V) { std::vector<int> ans(N); std::iota(ans.begin(), ans.end(), 1); int P2 = 1; while (P2 < N) P2 <<= 1; for (int P = 1; P < P2; P <<= 1) for (int k = P; k; k >>= 1) { std::vector<std::pair<int, int>> visited; for (int j = k % P; j < P2 - k; j += 2 * k) for (int i = 0; i < k && i + j + k < N; i++) if ((i + j) / (2 * P) == (i + j + k) / (2 * P)) { schedule(ans[i + j], ans[i + j + k]); visited.push_back({i + j, i + j + k}); } std::vector<int> visit_res = visit(); for (int i = 0; i < visit_res.size(); i++) if (!visit_res[i]) std::swap(ans[visited[i].first], ans[visited[i].second]); } answer(ans); }

Compilation message (stderr)

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