#include<bits/stdc++.h>
#define int long long
#define MOD 1000000007
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int arr[1005];
vector<pair<int,int>>v;
void swap2(int a,int b){
v.pb({b,a});
v.pb({a,b});
v.pb({b,a});
swap(arr[a],arr[b]);
}
int32_t main(){
int n,s;
cin>>n>>s;
for(int i=1;i<=n;i++){
cin>>arr[i];
}
for(int i=1;i<=n;i++){
for(int j=n;j>i;j--){
if(arr[j]<arr[j-1]){
swap2(j-1,j);
}
}
}
cout<<v.size()<<endl;
for(auto i:v)cout<<i.ff<<" "<<i.ss<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
3 ms |
340 KB |
Output is correct |
4 |
Correct |
21 ms |
744 KB |
Output is correct |
5 |
Correct |
28 ms |
848 KB |
Output is correct |
6 |
Correct |
23 ms |
848 KB |
Output is correct |
7 |
Correct |
21 ms |
848 KB |
Output is correct |
8 |
Correct |
22 ms |
848 KB |
Output is correct |
9 |
Correct |
26 ms |
848 KB |
Output is correct |
10 |
Correct |
22 ms |
848 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
52 ms |
1356 KB |
Output is correct |
13 |
Correct |
43 ms |
1356 KB |
Output is correct |
14 |
Correct |
43 ms |
1356 KB |
Output is correct |
15 |
Correct |
44 ms |
1356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
3 ms |
340 KB |
Output is correct |
4 |
Correct |
21 ms |
744 KB |
Output is correct |
5 |
Correct |
28 ms |
848 KB |
Output is correct |
6 |
Correct |
23 ms |
848 KB |
Output is correct |
7 |
Correct |
21 ms |
848 KB |
Output is correct |
8 |
Correct |
22 ms |
848 KB |
Output is correct |
9 |
Correct |
26 ms |
848 KB |
Output is correct |
10 |
Correct |
22 ms |
848 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
52 ms |
1356 KB |
Output is correct |
13 |
Correct |
43 ms |
1356 KB |
Output is correct |
14 |
Correct |
43 ms |
1356 KB |
Output is correct |
15 |
Correct |
44 ms |
1356 KB |
Output is correct |
16 |
Correct |
1 ms |
300 KB |
Output is correct |
17 |
Correct |
25 ms |
848 KB |
Output is correct |
18 |
Correct |
48 ms |
1000 KB |
Output is correct |
19 |
Correct |
37 ms |
1076 KB |
Output is correct |
20 |
Correct |
39 ms |
1096 KB |
Output is correct |
21 |
Correct |
43 ms |
988 KB |
Output is correct |
22 |
Correct |
40 ms |
1120 KB |
Output is correct |
23 |
Correct |
42 ms |
1124 KB |
Output is correct |
24 |
Correct |
39 ms |
972 KB |
Output is correct |
25 |
Correct |
49 ms |
1012 KB |
Output is correct |
26 |
Incorrect |
79 ms |
1724 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 |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
3 ms |
304 KB |
Output is correct |
4 |
Correct |
38 ms |
1072 KB |
Output is correct |
5 |
Incorrect |
981 ms |
18464 KB |
Integer 764742 violates the range [0, 40000] |
6 |
Halted |
0 ms |
0 KB |
- |