Submission #998006

# Submission time Handle Problem Language Result Execution time Memory
998006 2024-06-13T07:44:44 Z arbuzick MalnaRISC (COI21_malnarisc) C++17
0 / 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(i);
        } else {
            inds2.push_back(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 << ' ';
        }
        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 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 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 -
# 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 -
# 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 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -