Submission #672482

#TimeUsernameProblemLanguageResultExecution timeMemory
672482CyanmondMalnaRISC (COI21_malnarisc)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> int main() { int N; std::cin >> N; std::stack<std::pair<int, int>> swap_stack; auto cmpswp = [&](const int a, const int b) { if (a < N and b < N) { swap_stack.emplace(a, b); } }; auto flush = [&]() { while (not swap_stack.empty()) { const auto [a, b] = swap_stack.top(); swap_stack.pop(); std::cout << "CMPSWP" << ' ' << 'R' << a + 1 << ' ' << 'R' << b + 1; if (swap_stack.empty()) { std::cout << std::endl; } else { std::cout << ' '; } } }; int M = 1; while (M < N) { M *= 2; } std::cout << (int)log2(M) * (int)(log2(M + 1) + 1) / 2 << std::endl; for (int len = 2; len <= M; len *= 2) { for (int nl = len; nl >= 2; nl /= 2) { for (int i = 0; nl * i < M; ++i) { const int l = i * nl; for (int j = l; j < l + nl / 2; ++j) { if (i % 2 == 0) { cmpswp(j, j + nl / 2); } else { cmpswp(j + nl / 2, j); } } } flush(); } } }
#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...