# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
397277 | Pichon5 | Xor Sort (eJOI20_xorsort) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}