Submission #965177

# Submission time Handle Problem Language Result Execution time Memory
965177 2024-04-18T07:59:58 Z becaido MalnaRISC (COI21_malnarisc) C++17
40 / 100
1 ms 352 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 = 128;

int n, sz;
bool is[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 (is[i] == 0) {
            if (rev == 0) swap(is[i], is[i + len]);
        } else if (is[i + len] == 0) {
            if (rev) swap(is[i], is[i + len]);
        } else {
            if (rev) ans[k].pb(i + len, i);
            else ans[k].pb(i, 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;
    fill(is + 1, is + 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 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 352 KB Output isn't correct
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 Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -