#include <bits/stdc++.h>
//#include<ext/rope>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC target("avx2")
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
#define F first
#define S second
#define pb push_back
#define sz(x) int(x.size())
#define el '\n'
#define all(x) x.begin(), x.end()
using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;
typedef long long ll;
typedef long double ld;
typedef short int si;
typedef unsigned long long ull;
//typedef tree <ll, null_type, less <ll> , rb_tree_tag, tree_order_statistics_node_update> ordered_set;
vector <vector <pair <int, int> > > ans;
int mx_d = 0;
int D[10];
void solve(int l, int r, int d) {
if (l == r){
return;
}
while (d >= sz(ans)) {
ans.pb({});
}
int md = (l + r) >> 1;
for (int i = l, j = md + 1; i <= md; i++, j++) {
if (j <= r) {
ans[d].pb({i, j});
}
}
solve(l, md, d + 1);
solve(md + 1, r, d + 1);
}
void solve1(int l, int r, int d, bool need_ret) {
if (l == r){
return;
}
mx_d = max(mx_d, d);
while (d >= sz(ans)) {
ans.pb({});
}
int md = (l + r) >> 1;
if (!need_ret) {
solve1(l, md, d + 1, 0);
solve1(md + 1, r, d + 1, 0);
}
if (d >= 0) {
for (int i = l, j = md + 1; i <= md; i++, j++) {
if (j <= r) {
ans[d].pb({i, j});
}
}
if (!D[d]) {
D[d] = mx_d + 1;
}
int mx = D[d];
solve1(l, md, mx, 1);
solve1(md + 1, r, mx, 1);
}
}
int main()
{
// cerr.precision(7);
// cerr << fixed;
ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// in("23.in");
// in("input.txt");
// out("output.txt");
// clock_t start = clock();
int n;
cin >> n;
solve1(1, n, -1, 0);
solve(1, n, sz(ans));
cout << sz(ans) << el;
for (auto x : ans) {
for (auto [p1, p2] : x) {
cout << "CMPSWP R" << p1 << " R" << p2 << " ";
}
cout << el;
}
}
Compilation message
malnarisc.cpp: In function 'int main()':
malnarisc.cpp:100:19: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
100 | for (auto [p1, p2] : x) {
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
not sorted |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
not sorted |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
not sorted |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
not sorted |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
383 ms |
524292 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
405 ms |
524292 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
538 ms |
524288 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
371 ms |
524292 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
390 ms |
524292 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
378 ms |
524292 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |