#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=1e3+7;
int T[LIM], n;
vector<pair<int,int>>V;
void solve1() {
rep(i, n-1) V.pb({i+1, i});
rep(i, n) for(int j=i; j>0; --j) if(T[j-1]>T[j]) {
V.pb({j-1, j});
if(j-1>0) V.pb({j-1, j-2});
swap(T[j], T[j-1]);
}
for(int i=n-2; i>=0; --i) V.pb({i+1, i});
}
void solve2() {
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int s;
cin >> n >> s;
rep(i, n) cin >> T[i];
if(s==1) solve1();
else solve2();
cout << V.size() << '\n';
for(auto i : V) cout << i.st+1 << " " << i.nd+1 << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
672 KB |
Output is correct |
5 |
Correct |
2 ms |
604 KB |
Output is correct |
6 |
Correct |
2 ms |
604 KB |
Output is correct |
7 |
Correct |
2 ms |
604 KB |
Output is correct |
8 |
Correct |
2 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
3 ms |
868 KB |
Output is correct |
13 |
Correct |
3 ms |
736 KB |
Output is correct |
14 |
Correct |
2 ms |
736 KB |
Output is correct |
15 |
Correct |
3 ms |
856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
672 KB |
Output is correct |
5 |
Correct |
2 ms |
604 KB |
Output is correct |
6 |
Correct |
2 ms |
604 KB |
Output is correct |
7 |
Correct |
2 ms |
604 KB |
Output is correct |
8 |
Correct |
2 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
3 ms |
868 KB |
Output is correct |
13 |
Correct |
3 ms |
736 KB |
Output is correct |
14 |
Correct |
2 ms |
736 KB |
Output is correct |
15 |
Correct |
3 ms |
856 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
2 ms |
604 KB |
Output is correct |
18 |
Correct |
3 ms |
856 KB |
Output is correct |
19 |
Correct |
3 ms |
860 KB |
Output is correct |
20 |
Correct |
2 ms |
736 KB |
Output is correct |
21 |
Correct |
3 ms |
736 KB |
Output is correct |
22 |
Correct |
2 ms |
860 KB |
Output is correct |
23 |
Correct |
2 ms |
736 KB |
Output is correct |
24 |
Correct |
3 ms |
736 KB |
Output is correct |
25 |
Correct |
2 ms |
736 KB |
Output is correct |
26 |
Correct |
6 ms |
992 KB |
Output is correct |
27 |
Correct |
6 ms |
1248 KB |
Output is correct |
28 |
Correct |
5 ms |
992 KB |
Output is correct |
29 |
Correct |
4 ms |
992 KB |
Output is correct |
30 |
Correct |
5 ms |
992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Not sorted |
2 |
Halted |
0 ms |
0 KB |
- |