Submission #420909

# Submission time Handle Problem Language Result Execution time Memory
420909 2021-06-08T14:48:17 Z HappyPacMan MalnaRISC (COI21_malnarisc) C++14
0 / 100
2 ms 332 KB
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
vector<pair<int,int> > res;

vi merge(vi a,vi b){
    if(a.size() > b.size()) swap(a,b);
    for(int i=0;i<a.size();i++){
        for(int j=i-1;j>0;j--){
            res.emplace_back(b[j-1],b[j]);
        }
        res.emplace_back(a[i],b[0]);
    }
    for(int i=1;i<b.size();i++) res.emplace_back(b[i-1],b[i]);
    for(int u : b) a.push_back(u);
    return a;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    queue<vi> q;
    for(int i=0;i<n;i++){
        vi nw = {i+1};
        q.push(nw);
    }
    while(q.size() > 1){
        auto u = q.front(); q.pop(); auto v = q.front(); q.pop();
        q.push(merge(u,v));
    }
    cout << res.size() << '\n';
    for(auto u : res){
        cout << "CMPSWP R" << u.first << " R" << u.second << '\n';
    }
}

Compilation message

malnarisc.cpp: In function 'vi merge(vi, vi)':
malnarisc.cpp:8:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for(int i=0;i<a.size();i++){
      |                 ~^~~~~~~~~
malnarisc.cpp:14:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for(int i=1;i<b.size();i++) res.emplace_back(b[i-1],b[i]);
      |                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 312 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB not sorted