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>
#define int long long
#define MOD 1000000007
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int arr[1005];
vector<pair<int,int>>v;
void swap2(int a,int b){
v.pb({b,a});
v.pb({a,b});
v.pb({b,a});
swap(arr[a],arr[b]);
}
int32_t main(){
int n,s;
cin>>n>>s;
for(int i=1;i<=n;i++){
cin>>arr[i];
}
for(int i=1;i<=n;i++){
for(int j=n;j>i;j--){
if(arr[j]<arr[j-1]){
swap2(j-1,j);
}
}
}
cout<<v.size()<<endl;
for(auto i:v)cout<<i.ff<<" "<<i.ss<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |