#include <iostream>
#define MAX_N 1000
#define MAX_K 40000
using namespace std;
struct answer {
int x, y;
};
int v[MAX_N];
answer ans[MAX_K];
int main() {
int n, s, k, i, j, p;
cin >> n >> s;
for ( i = 0; i < n; i++ )
cin >> v[i];
k = 0;
for ( i = 0; i < n; i++ ) {
p = i;
for ( j = i + 1; j < n; j++ ) {
if ( v[j] < v[p] )
p = j;
}
if ( p != i ) {
swap( v[i], v[p] );
while ( p >= i ) {
ans[k] = { p, p + 1 };
ans[k + 1] = { p + 1, p };
ans[k + 2] = { p, p + 1 };
k += 3;
p--;
}
}
}
cout << k << "\n";
for ( i = 0; i < k; i++ )
cout << ans[i].x << " " << ans[i].y << "\n";
return 0;
}
# |
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 |
- |
# |
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 |
- |
# |
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 |
- |