Submission #1003587

#TimeUsernameProblemLanguageResultExecution timeMemory
1003587pedroslreyMalnaRISC (COI21_malnarisc)C++17
40 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; using ops = vector<vector<pair<int, int>>>; ops faz_morro(int n) { if (n == 0) return {}; ops ans(1); int m = (1 << (n-1)); for (int i = 0; i < m; ++i) ans.back().emplace_back(i, i + m); auto xss = faz_morro(n-1); for (auto &xs: xss) { ans.emplace_back(); for (auto [a, b]: xs) { ans.back().emplace_back(a, b); ans.back().emplace_back(a + m, b + m); } } return ans; } ops solve(int n) { if (n == 0) return {}; auto xss = solve(n-1); ops ans; for (auto &xs: xss) { ans.emplace_back(); for (auto [a, b]: xs) ans.back().emplace_back(a, b); int m = 1 << (n-1); for (auto [a, b]: xs) ans.back().emplace_back(b + m, a + m); } auto yss = faz_morro(n); for (auto &ys: yss) { ans.emplace_back(); for (auto y: ys) ans.back().push_back(y); } return ans; } int main() { int n; cin >> n; ops ans = solve(__lg(n)); cout << ans.size() << "\n"; for (auto &xs: ans) { for (auto [a, b]: xs) cout << "CMPSWP R" << a + 1 << " R" << b + 1 << " "; cout << "\n"; } }
#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...