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 "bits/stdc++.h"
using namespace std;
void solve(){
int n, s; cin>>n>>s;
vector<int> a(n);
for(auto& x : a) cin>>x;
vector<array<int, 2>> rr;
auto swwap = [&](int i){
rr.push_back({i + 1, i});
rr.push_back({i, i + 1});
rr.push_back({i + 1, i});
};
for(int i=0;i<n;i++){
int p = i;
for(int j=i+1;j<n;j++){
if(a[j] < a[p]) p = j;
}
while(p > i){
swap(a[p], a[p - 1]);
swwap(p);
p--;
}
}
cout<<(int)rr.size()<<"\n";
for(auto x : rr) cout<<x[0]<<" "<<x[1]<<"\n";
}
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int t = 1;
//~ cin>>t;
while(t--) solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |