#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 - 1});
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 |
1 |
Incorrect |
0 ms |
204 KB |
Not adjacent |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Not adjacent |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Integer 0 violates the range [1, 5] |
2 |
Halted |
0 ms |
0 KB |
- |