Submission #998008

# Submission time Handle Problem Language Result Execution time Memory
998008 2024-06-13T07:45:40 Z arbuzick MalnaRISC (COI21_malnarisc) C++17
35.6531 / 100
1 ms 604 KB
#include <bits/stdc++.h>

using namespace std;

int sort(vector<int> inds, vector<vector<pair<int, int>>> &ans) {
    if (inds.size() == 1) {
        return 0;
    }
    vector<int> inds1, inds2;
    for (int i = 0; i < (int)inds.size(); ++i) {
        if (i % 2 == 0) {
            inds1.push_back(inds[i]);
        } else {
            inds2.push_back(inds[i]);
        }
    }
    int pos = max(sort(inds1, ans), sort(inds2, ans));
    for (int i = 0; i + 1 < (int)inds.size(); ++i) {
        if (ans.size() <= pos) {
            ans.push_back({});
        }
        for (int j = i; j + 1 < (int)inds.size(); j += 2) {
            ans[pos].emplace_back(inds[j], inds[j + 1]);
        }
        pos++;
    }
    return pos;
}

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    iota(a.begin(), a.end(), 1);
    vector<vector<pair<int, int>>> ans;
    sort(a, ans);
    cout << ans.size() << '\n';
    for (auto v : ans) {
        for (auto p : v) {
            cout << "CMPSWP R" << p.first << " R" << p.second;
            if (p != v.back()) {
                cout << ' ';
            }
        }
        cout << '\n';
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Compilation message

malnarisc.cpp: In function 'int sort(std::vector<int>, std::vector<std::vector<std::pair<int, int> > >&)':
malnarisc.cpp:19:24: warning: comparison of integer expressions of different signedness: 'std::vector<std::vector<std::pair<int, int> > >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   19 |         if (ans.size() <= pos) {
      |             ~~~~~~~~~~~^~~~~~
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 344 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 344 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 344 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 344 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 348 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 344 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 604 KB Partially correct