#include "bits/stdc++.h"
#define int long long
using namespace std;
const int sz = 155;
int a[sz];
signed main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n, s;
cin >> n >> s;
for (int i = 1; i <= n; i ++)
cin >> a[i];
vector<pair<int,int>> v;
for (int i = 1; i <= n; i ++)
for (int j = n-1; i <= j; j --)
if (a[j+1] < a[j]) {
v.push_back(make_pair(j, j+1));
v.push_back(make_pair(j+1, j));
v.push_back(make_pair(j, j+1));
swap(a[j], a[j+1]);
}
cout << v.size() << '\n';
for (auto& p : v)
cout << p.first << ' ' << p.second << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
736 KB |
Output is correct |
5 |
Correct |
2 ms |
992 KB |
Output is correct |
6 |
Correct |
2 ms |
992 KB |
Output is correct |
7 |
Correct |
2 ms |
992 KB |
Output is correct |
8 |
Correct |
2 ms |
992 KB |
Output is correct |
9 |
Correct |
2 ms |
992 KB |
Output is correct |
10 |
Correct |
2 ms |
992 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
4 ms |
1608 KB |
Output is correct |
13 |
Correct |
5 ms |
1500 KB |
Output is correct |
14 |
Correct |
4 ms |
1496 KB |
Output is correct |
15 |
Correct |
4 ms |
1500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
736 KB |
Output is correct |
5 |
Correct |
2 ms |
992 KB |
Output is correct |
6 |
Correct |
2 ms |
992 KB |
Output is correct |
7 |
Correct |
2 ms |
992 KB |
Output is correct |
8 |
Correct |
2 ms |
992 KB |
Output is correct |
9 |
Correct |
2 ms |
992 KB |
Output is correct |
10 |
Correct |
2 ms |
992 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
4 ms |
1608 KB |
Output is correct |
13 |
Correct |
5 ms |
1500 KB |
Output is correct |
14 |
Correct |
4 ms |
1496 KB |
Output is correct |
15 |
Correct |
4 ms |
1500 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
2 ms |
992 KB |
Output is correct |
18 |
Runtime error |
4 ms |
1244 KB |
Execution killed with signal 11 |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Runtime error |
4 ms |
1244 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |