Submission #997966

#TimeUsernameProblemLanguageResultExecution timeMemory
997966green_gold_dogMalnaRISC (COI21_malnarisc)C++17
76.85 / 100
1 ms348 KiB
//#pragma GCC optimize("Ofast") //#pragma GCC target("avx,avx2,sse,sse2,sse3,ssse3,sse4,abm,popcnt,mmx") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef double db; typedef long double ldb; typedef complex<double> cd; constexpr ll INF64 = 9'000'000'000'000'000'000, INF32 = 2'000'000'000, MOD = 1'000'000'007, MAXC = 1'000; constexpr db PI = acos(-1); constexpr bool IS_FILE = false, IS_TEST_CASES = false; random_device rd; mt19937 rnd32(rd()); mt19937_64 rnd64(rd()); template<typename T> bool assign_max(T& a, T b) { if (b > a) { a = b; return true; } return false; } template<typename T> bool assign_min(T& a, T b) { if (b < a) { a = b; return true; } return false; } template<typename T> T square(T a) { return a * a; } template<> struct std::hash<pair<ll, ll>> { ll operator() (pair<ll, ll> p) const { return ((__int128)p.first * MOD + p.second) % INF64; } }; void rec(ll l, ll r, vector<vector<pair<ll, ll>>>& op, vector<ll>& lu) { if (r - l <= 0) { return; } ll mid = (l + r - 1) / 2; rec(l, mid, op, lu); rec(mid + 1, r, op, lu); ll fl = l, fr = mid; ll sl = mid + 1, sr = r; while (sl <= sr) { ll now = sr; for (ll i = fr; i >= fl; i--) { ll num = max(lu[now], lu[i]) + 1; op[num].emplace_back(i, now); lu[now] = num; lu[i] = num; now--; } sr--; if (now < sl) { fl++; } } } void solve() { ll n; cin >> n; vector<vector<pair<ll, ll>>> op(MAXC); vector<ll> lu(n + 1, -1); rec(1, n, op, lu); while (op.back().empty()) { op.pop_back(); } cout << op.size() << '\n'; for (auto i : op) { for (auto[a, b] : i) { cout << "CMPSWP " << "R" << a << ' ' << "R" << b << ' '; } cout << '\n'; } } int main() { if (IS_FILE) { freopen("", "r", stdin); freopen("", "w", stdout); } ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll t = 1; if (IS_TEST_CASES) { cin >> t; } for (ll i = 0; i < t; i++) { solve(); } }

Compilation message (stderr)

malnarisc.cpp: In function 'int main()':
malnarisc.cpp:95:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   95 |                 freopen("", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~
malnarisc.cpp:96:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   96 |                 freopen("", "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~
#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...