#include <bits/stdc++.h>
using namespace std;
int main() {
int n, s;
cin >> n >> s;
vector<int> a(n), b(n);
vector<pair<int,int>> op;
map<int,int> pos;
for(int i = 0; i < n; i++) {
cin >> a[i];
b[i] = a[i];
pos[a[i]] = i;
}
sort(b.begin(), b.end());
for(int i = 0; i < n; i++) {
for(int j = pos[b[i]]; j > i; j--) {
op.push_back({j-1, j});
op.push_back({j, j-1});
op.push_back({j-1, j});
pos[a[j-1]] = j;
a[j] = a[j-1];
}
pos[b[i]] = i;
a[i] = b[i];
}
cout << op.size() << "\n";
for(auto i : op) cout << i.first << " " << i.second << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Integer 0 violates the range [1, 5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Integer 0 violates the range [1, 5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Integer 0 violates the range [1, 5] |
2 |
Halted |
0 ms |
0 KB |
- |