#include <iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb push_back
#define mpr make_pair
#define lb lower_bound
#define ld long double
#define ub upper_bound
map<pair<int, int>, bool> m;
int n, s;
int a[100005];
void solve() {
cin >> n >> s;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector<pair<int, int> > ans;
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (a[j] > a[j + 1]) {
ans.push_back(mpr(j + 1, j + 2));
ans.push_back(mpr(j + 2, j + 1));
ans.push_back(mpr(j + 1, j + 2));
swap(a[j], a[j + 1]);
}
}
}
cout << ans.size() << endl;
for (auto i : ans) {
cout << i.first << ' ' << i.second << endl;
}
}
int main() {
/*cout.setf(ios::fixed | ios::showpoint);
cout.precision(6);*/
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int t = 1;
//cin >> t;
while (t--) {
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
3 ms |
332 KB |
Output is correct |
4 |
Correct |
25 ms |
644 KB |
Output is correct |
5 |
Correct |
29 ms |
716 KB |
Output is correct |
6 |
Correct |
27 ms |
636 KB |
Output is correct |
7 |
Correct |
28 ms |
716 KB |
Output is correct |
8 |
Correct |
28 ms |
716 KB |
Output is correct |
9 |
Correct |
30 ms |
668 KB |
Output is correct |
10 |
Correct |
29 ms |
716 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
60 ms |
976 KB |
Output is correct |
13 |
Correct |
55 ms |
976 KB |
Output is correct |
14 |
Correct |
55 ms |
976 KB |
Output is correct |
15 |
Correct |
55 ms |
976 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
3 ms |
332 KB |
Output is correct |
4 |
Correct |
25 ms |
644 KB |
Output is correct |
5 |
Correct |
29 ms |
716 KB |
Output is correct |
6 |
Correct |
27 ms |
636 KB |
Output is correct |
7 |
Correct |
28 ms |
716 KB |
Output is correct |
8 |
Correct |
28 ms |
716 KB |
Output is correct |
9 |
Correct |
30 ms |
668 KB |
Output is correct |
10 |
Correct |
29 ms |
716 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
60 ms |
976 KB |
Output is correct |
13 |
Correct |
55 ms |
976 KB |
Output is correct |
14 |
Correct |
55 ms |
976 KB |
Output is correct |
15 |
Correct |
55 ms |
976 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
30 ms |
688 KB |
Output is correct |
18 |
Correct |
54 ms |
768 KB |
Output is correct |
19 |
Correct |
50 ms |
852 KB |
Output is correct |
20 |
Correct |
47 ms |
964 KB |
Output is correct |
21 |
Correct |
48 ms |
848 KB |
Output is correct |
22 |
Correct |
52 ms |
776 KB |
Output is correct |
23 |
Correct |
51 ms |
840 KB |
Output is correct |
24 |
Correct |
47 ms |
860 KB |
Output is correct |
25 |
Correct |
48 ms |
804 KB |
Output is correct |
26 |
Incorrect |
98 ms |
1212 KB |
Integer 59568 violates the range [0, 40000] |
27 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
4 ms |
332 KB |
Output is correct |
4 |
Correct |
50 ms |
804 KB |
Output is correct |
5 |
Execution timed out |
1076 ms |
11488 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |