#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool mnto(T& a, T b) {return a > b ? a = b, 1 : 0;}
template <class T>
inline bool mxto(T& a, T b) {return a < b ? a = b, 1: 0;}
#define mnto(x, y) x = min(x, (__typeof__(x)) y)
#define mxto(x, y) x = max(x, (__typeof__(x)) y)
#define REP(i, s, e) for (int i = s; i < e; i++)
#define RREP(i, s, e) for (int i = s; i >= e; i--)
typedef long long ll;
typedef long double ld;
#define MP make_pair
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
#define MT make_tuple
typedef tuple<int, int, int> iii;
#define ALL(_a) _a.begin(), _a.end()
#define pb emplace_back
typedef vector<int> vi;
typedef vector<ii> vii;
#define INF 1000000005
#define LINF 1000000000000000005
#define MOD 1000000007
#define MAXN 200005
int n;
vector<vii> ans;
int main() {
scanf("%d", &n);
if (n == 8 || n == 16 || n == 32 || n == 64) {
int mx = n;
while (mx >= 2) {
vii res;
int cur = mx, prv = 0;
REP (j, 1, n + 1) {
if (j > cur - (j - prv) + 1) {
prv = cur;
j = cur + 1;
cur += mx;
if (cur > n) {
break;
}
}
res.pb(j, cur - (j - prv) + 1);
}
ans.pb(res);
mx /= 2;
}
} else {
REP (i, 0, n - 1) {
vii res;
for (int j = 1; j + 1 <= n; j += 2) {
res.pb(j, j + 1);
}
if (!res.empty()) ans.pb(res);
res.clear();
for (int j = 2; j + 1 <= n; j += 2) {
res.pb(j, j + 1);
}
if (!res.empty()) ans.pb(res);
}
}
printf("%d\n", (int) ans.size());
REP (i, 0, ans.size()) {
for (ii i : ans[i]) {
printf("CMPSWP R%d R%d ", i.FI, i.SE);
}
printf("\n");
}
return 0;
}
Compilation message
malnarisc.cpp: In function 'int main()':
malnarisc.cpp:10:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
10 | #define REP(i, s, e) for (int i = s; i < e; i++)
......
70 | REP (i, 0, ans.size()) {
| ~~~~~~~~~~~~~~~~
malnarisc.cpp:70:2: note: in expansion of macro 'REP'
70 | REP (i, 0, ans.size()) {
| ^~~
malnarisc.cpp:35:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
35 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
not sorted |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
204 KB |
Partially correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
not sorted |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
not sorted |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
332 KB |
Partially correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
not sorted |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
2 ms |
332 KB |
Partially correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
2 ms |
332 KB |
Partially correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
3 ms |
460 KB |
Partially correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
4 ms |
460 KB |
Partially correct |