// Muallif: Mansuraliyev Husanboy Murotali o'g'li >> NamPS
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(a) a.begin(), a.end()
#define F first
#define S second
// 0-9 >> 48-57; A-Z>>65-90 and a-z>>97-122 respectively;
void solve(){
int n,s; cin>>n>>s;
int a[n];
for(int i=0;i<n;i++) cin>>a[i];
vector<pair<int,int>> ans;
for(int i=1;i<n;i++){
for(int j=0;j<n-i;j++){
if(a[j]>a[j+1]){
ans.push_back({j,j+1});
ans.push_back({j+1,j});
ans.push_back({j,j+1});
swap(a[j+1],a[j]);
}
}
}
cout<<ans.size()<<"\n";
for(auto u:ans){
cout<<u.F+1<<' '<<u.S+1<<"\n";
}
}
int main(){
ios;
//int t=1; cin>>t; while(t--)
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
3 ms |
596 KB |
Output is correct |
5 |
Correct |
4 ms |
600 KB |
Output is correct |
6 |
Correct |
4 ms |
600 KB |
Output is correct |
7 |
Correct |
4 ms |
600 KB |
Output is correct |
8 |
Correct |
3 ms |
684 KB |
Output is correct |
9 |
Correct |
3 ms |
600 KB |
Output is correct |
10 |
Correct |
3 ms |
600 KB |
Output is correct |
11 |
Correct |
1 ms |
264 KB |
Output is correct |
12 |
Correct |
6 ms |
920 KB |
Output is correct |
13 |
Correct |
6 ms |
964 KB |
Output is correct |
14 |
Correct |
6 ms |
868 KB |
Output is correct |
15 |
Correct |
6 ms |
1020 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
3 ms |
596 KB |
Output is correct |
5 |
Correct |
4 ms |
600 KB |
Output is correct |
6 |
Correct |
4 ms |
600 KB |
Output is correct |
7 |
Correct |
4 ms |
600 KB |
Output is correct |
8 |
Correct |
3 ms |
684 KB |
Output is correct |
9 |
Correct |
3 ms |
600 KB |
Output is correct |
10 |
Correct |
3 ms |
600 KB |
Output is correct |
11 |
Correct |
1 ms |
264 KB |
Output is correct |
12 |
Correct |
6 ms |
920 KB |
Output is correct |
13 |
Correct |
6 ms |
964 KB |
Output is correct |
14 |
Correct |
6 ms |
868 KB |
Output is correct |
15 |
Correct |
6 ms |
1020 KB |
Output is correct |
16 |
Correct |
1 ms |
320 KB |
Output is correct |
17 |
Correct |
3 ms |
600 KB |
Output is correct |
18 |
Correct |
5 ms |
856 KB |
Output is correct |
19 |
Correct |
5 ms |
856 KB |
Output is correct |
20 |
Correct |
5 ms |
856 KB |
Output is correct |
21 |
Correct |
5 ms |
836 KB |
Output is correct |
22 |
Correct |
6 ms |
856 KB |
Output is correct |
23 |
Correct |
5 ms |
856 KB |
Output is correct |
24 |
Correct |
6 ms |
872 KB |
Output is correct |
25 |
Correct |
5 ms |
856 KB |
Output is correct |
26 |
Incorrect |
10 ms |
1208 KB |
Integer 59568 violates the range [0, 40000] |
27 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
5 ms |
856 KB |
Output is correct |
5 |
Incorrect |
119 ms |
12468 KB |
Integer 764742 violates the range [0, 40000] |
6 |
Halted |
0 ms |
0 KB |
- |