Submission #965145

# Submission time Handle Problem Language Result Execution time Memory
965145 2024-04-18T07:43:31 Z becaido MalnaRISC (COI21_malnarisc) C++17
60 / 100
1 ms 460 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,popcnt,sse4,abm")
#include <bits/stdc++.h>
using namespace std;

#ifdef WAIMAI
#define debug(HEHE...) cout << "[" << #HEHE << "] : ", dout(HEHE)
void dout() {cout << '\n';}
template<typename T, typename...U>
void dout(T t, U...u) {cout << t << (sizeof...(u) ? ", " : ""), dout(u...);}
#else
#define debug(...) 7122
#endif

#define ll long long
#define Waimai ios::sync_with_stdio(false), cin.tie(0)
#define FOR(x,a,b) for (int x = a, I = b; x <= I; x++)
#define pb emplace_back
#define F first
#define S second

const int SIZE = 130;

int n, sz;
int a[SIZE];

int m;
vector<pair<int, int>> ans[SIZE];

int bmerge(int l, int r, bool rev, int k) {
    if (l == r) return k;
    int mid = (l + r) / 2, len = mid - l + 1;
    FOR (i, l, mid) {
        if (a[i] == 0) {
            if (rev == 0) swap(a[i], a[i + len]);
        } else if (a[i + len] == 0) {
            if (rev) swap(a[i], a[i + len]);
        } else {
            if (rev) ans[k].pb(a[i + len], a[i]);
            else ans[k].pb(a[i], a[i + len]);
        }
    }
    bmerge(l, mid, rev, k + 1);
    return bmerge(mid + 1, r, rev, k + 1);
}
int bsort(int l, int r, bool rev, int k) {
    if (l == r) return k;
    int mid = (l + r) / 2;
    bsort(l, mid, 0, k);
    k = bsort(mid + 1, r, 1, k);
    return bmerge(l, r, rev, k);
}

void solve() {
    cin >> n;
    sz = 1;
    while (sz < n) sz <<= 1;
    iota(a + 1, a + n + 1, 1);
    m = bsort(1, sz, 0, 1) - 1;
    cout << m << '\n';
    FOR (i, 1, m) {
        for (auto [x, y] : ans[i]) cout << "CMPSWP" << ' ' << "R" << x << ' ' << "R" << y << ' ';
        cout << '\n';
    }
}

int main() {
    Waimai;
    solve();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct