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 ll long long
#define ld long double
using namespace std;
const int mxn = 1005;
const int SQRT = 500;
const int inf = 1e18;
const int mod = 998244353;
const ld eps = 1e-9;
vector<pair<int,int> > res;
int A[mxn];
void xswap(int a,int b){
res.push_back({b,a});
res.push_back({a,b});
res.push_back({b,a});
swap(A[a], A[b]);
}
void solve(int T){
int n,s;
cin>>n>>s;
for(int i = 0;i<n;i++)cin>>A[i];
while(2 + 2 == 4){
bool found = false;
for(int i = 0;i<n-1;i++){
if(A[i] > A[i+1]){
xswap(i, i+1);
found = true;
}
}
if(!found)break;
}
cout<<res.size()<<endl;
for(auto p: res){
cout<<p.first+1<<" "<<p.second+1<<endl;
}
}
int32_t main(){
#ifdef ONLINE_JUDGE
ios::sync_with_stdio(false);
cin.tie(0);
#endif
int t = 1;
//cin>>t;
for(int i = 1;i<=t;i++)solve(i);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |