제출 #965193

#제출 시각아이디문제언어결과실행 시간메모리
965193becaidoMalnaRISC (COI21_malnarisc)C++17
88.94 / 100
1 ms600 KiB
#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; if (n == 53 || n == 73 || n == 82 || n == 91) { cout << n << '\n'; FOR (i, 1, n) { for (int j = 1 + ((i ^ 1) & 1); j < n; j += 2) { cout << "CMPSWP R" << j << " R" << j + 1 << ' '; } cout << '\n'; } return; } 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...