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;
#define endl '\n'
#define ll long long
const ll sz=100005;
int main(){
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll n, s;
cin>>n>>s;
ll m[n+1];
for(int i=1; i<=n; i++){
cin>>m[i];
}
vector<pair<ll, ll>>v;
for(int j=1; j<n; j++){
for(int i=2; i<=n; i++){
if(m[i]<=m[i-1]){
v.push_back({i, i-1});
v.push_back({i-1, i});
v.push_back({i, i-1});
swap(m[i], m[i-1]);
}
}
}
cout<<v.size()<<endl;
for(auto i:v){
cout<<i.first<<' '<<i.second<<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... |