This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using std::vector;
using std::array;
using std::pair;
using std::tuple;
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int N;
std::cin >> N;
vector<std::string> ans;
vector<pair<int, int>> query;
const auto flush = [&] {
std::stringstream s;
bool f = true;
for (const auto& [i, j] : query) {
if (f) {
f = false;
} else {
s << ' ';
}
s << "CMPSWP R" << std::to_string(i + 1) << " R" << std::to_string(j + 1);
}
ans.push_back(s.str());
query.clear();
};
for (int len = 1; len < N; len *= 2) {
for (int i = 0; i < N; i += len * 2) {
for (int j = 0; j < len; ++j) {
const int l = i + j;
const int r = i + 2 * len - j - 1;
if (r < N) {
query.emplace_back(l, r);
}
}
}
flush();
for (int w = len; w > 1; w /= 2) {
for (int i = 0; i < N; i += w) {
for (int j = 0; j < w / 2; ++j) {
const int l = i + j;
const int r = i + j + w / 2;
if (r < N) {
query.emplace_back(l, r);
}
}
}
flush();
}
}
std::cout << ans.size() << '\n';
for (const auto& s : ans) {
std::cout << s << '\n';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |