#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
const ll sz=100005;
int main(){
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll n, s;
cin>>n>>s;
ll m[n+1];
for(int i=1; i<=n; i++){
cin>>m[i];
}
vector<pair<ll, ll>>v;
for(int j=1; j<n; j++){
for(int i=2; i<=n; i++){
if(m[i]<=m[i-1]){
v.push_back({i, i-1});
v.push_back({i-1, i});
v.push_back({i, i-1});
swap(m[i], m[i-1]);
}
}
}
cout<<v.size()<<endl;
for(auto i:v){
cout<<i.first<<' '<<i.second<<endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
320 KB |
Output is correct |
4 |
Correct |
2 ms |
712 KB |
Output is correct |
5 |
Correct |
3 ms |
960 KB |
Output is correct |
6 |
Correct |
3 ms |
856 KB |
Output is correct |
7 |
Correct |
3 ms |
856 KB |
Output is correct |
8 |
Correct |
3 ms |
964 KB |
Output is correct |
9 |
Correct |
3 ms |
984 KB |
Output is correct |
10 |
Correct |
3 ms |
888 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
5 ms |
1492 KB |
Output is correct |
13 |
Correct |
5 ms |
1492 KB |
Output is correct |
14 |
Correct |
5 ms |
1468 KB |
Output is correct |
15 |
Correct |
5 ms |
1476 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
320 KB |
Output is correct |
4 |
Correct |
2 ms |
712 KB |
Output is correct |
5 |
Correct |
3 ms |
960 KB |
Output is correct |
6 |
Correct |
3 ms |
856 KB |
Output is correct |
7 |
Correct |
3 ms |
856 KB |
Output is correct |
8 |
Correct |
3 ms |
964 KB |
Output is correct |
9 |
Correct |
3 ms |
984 KB |
Output is correct |
10 |
Correct |
3 ms |
888 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
5 ms |
1492 KB |
Output is correct |
13 |
Correct |
5 ms |
1492 KB |
Output is correct |
14 |
Correct |
5 ms |
1468 KB |
Output is correct |
15 |
Correct |
5 ms |
1476 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
3 ms |
984 KB |
Output is correct |
18 |
Correct |
4 ms |
1108 KB |
Output is correct |
19 |
Correct |
6 ms |
1028 KB |
Output is correct |
20 |
Correct |
4 ms |
1108 KB |
Output is correct |
21 |
Correct |
4 ms |
1108 KB |
Output is correct |
22 |
Correct |
4 ms |
1108 KB |
Output is correct |
23 |
Correct |
4 ms |
1108 KB |
Output is correct |
24 |
Correct |
4 ms |
1108 KB |
Output is correct |
25 |
Correct |
4 ms |
1108 KB |
Output is correct |
26 |
Incorrect |
8 ms |
1664 KB |
Integer 59568 violates the range [0, 40000] |
27 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
4 ms |
1012 KB |
Output is correct |
5 |
Incorrect |
109 ms |
18416 KB |
Integer 764742 violates the range [0, 40000] |
6 |
Halted |
0 ms |
0 KB |
- |