Submission #397277

# Submission time Handle Problem Language Result Execution time Memory
397277 2021-05-01T19:31:57 Z Pichon5 Xor Sort (eJOI20_xorsort) C++17
Compilation error
0 ms 0 KB
#include <iostream>
#include <bits/stdc++.h>
#define vi vector<int>
#define pb push_back
#define F first
#define S second
#define ll long long
#define vll vector<ll>
using namespace std;

int main()
{
    int x,n,s;
    cin>>n>>s;
    vi v;
    vector<pair<int,int> >E;
    for(int i=0;i<n;i++){
        cin>>x;
        v.pb(x);
    }
    for(int i=0;i<n;i++){
        for(int l=0;l<n-1;l++){
            if(v[l]>v[l+1]){
                E.pb({l+1,l+2});E.pb({l+2,l+1});E.pb({l+1,l+2});
                swap(v[l],v[l+1]);
            }
        }
    cout<<E.size()<<endl;
    for(int i=0;i<E.size();i++){
        cout<<E[i].F<<" "<<E[i].S<<endl;
    }

    return 0;
}

Compilation message

xorsort.cpp: In function 'int main()':
xorsort.cpp:29:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for(int i=0;i<E.size();i++){
      |                 ~^~~~~~~~~
xorsort.cpp:34:1: error: expected '}' at end of input
   34 | }
      | ^
xorsort.cpp:12:1: note: to match this '{'
   12 | {
      | ^