This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Muallif: Mansuraliyev Husanboy Murotali o'g'li >> NamPS
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(a) a.begin(), a.end()
#define F first
#define S second
// 0-9 >> 48-57; A-Z>>65-90 and a-z>>97-122 respectively;
void solve(){
int n,s; cin>>n>>s;
int a[n];
for(int i=0;i<n;i++) cin>>a[i];
vector<pair<int,int>> ans;
for(int i=1;i<n;i++){
for(int j=0;j<n-i;j++){
if(a[j]>a[j+1]){
ans.push_back({j,j+1});
ans.push_back({j+1,j});
ans.push_back({j,j+1});
swap(a[j+1],a[j]);
}
}
}
cout<<ans.size()<<"\n";
for(auto u:ans){
cout<<u.F+1<<' '<<u.S+1<<"\n";
}
}
int main(){
ios;
//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... |