#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define pll pair <ll,ll>
#define F first
#define S second
#define int ll
#define pb push_back
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
using namespace __gnu_pbds;
typedef tree <pll,null_type,less <pll>,rb_tree_tag,tree_order_statistics_node_update> orduk;
typedef tree <ll,null_type,less <ll>,rb_tree_tag,tree_order_statistics_node_update> orduk2;
ll n,type;
vector <ll> a;
inline void init() {
cin>>n>>type;
a.resize(n);
for (int i = 0;i < n;i++)
cin>>a[i];
}
vector <pll> ans;
inline void output() {
cout<<ans.size()<<'\n';
for (auto to:ans)
cout<<to.F<<" "<<to.S<<'\n';
exit(0);
}
inline void solve() {
while (1) {
bool found = true;
for (int i = n - 1;i > 0;i--)
if (a[i] < a[i - 1]) {
ans.pb({i + 1,i});
ans.pb({i, i + 1});
ans.pb({i + 1,i});
swap(a[i],a[i - 1]);
found = false;
break;
}
if (found == true) break;
}
}
int32_t main() {
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
IOS;
int m;
m = 10;
m-=9;
while (m--)
{
init();
solve();
output();
}
}
/*written by Traduttore*/
/*waiting for a miracle...*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
4 ms |
752 KB |
Output is correct |
5 |
Correct |
6 ms |
1008 KB |
Output is correct |
6 |
Correct |
6 ms |
1008 KB |
Output is correct |
7 |
Correct |
4 ms |
1008 KB |
Output is correct |
8 |
Correct |
4 ms |
1008 KB |
Output is correct |
9 |
Correct |
5 ms |
1008 KB |
Output is correct |
10 |
Correct |
5 ms |
1008 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
8 ms |
1516 KB |
Output is correct |
13 |
Correct |
8 ms |
1516 KB |
Output is correct |
14 |
Correct |
8 ms |
1516 KB |
Output is correct |
15 |
Correct |
8 ms |
1516 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
4 ms |
752 KB |
Output is correct |
5 |
Correct |
6 ms |
1008 KB |
Output is correct |
6 |
Correct |
6 ms |
1008 KB |
Output is correct |
7 |
Correct |
4 ms |
1008 KB |
Output is correct |
8 |
Correct |
4 ms |
1008 KB |
Output is correct |
9 |
Correct |
5 ms |
1008 KB |
Output is correct |
10 |
Correct |
5 ms |
1008 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
8 ms |
1516 KB |
Output is correct |
13 |
Correct |
8 ms |
1516 KB |
Output is correct |
14 |
Correct |
8 ms |
1516 KB |
Output is correct |
15 |
Correct |
8 ms |
1516 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
4 ms |
1008 KB |
Output is correct |
18 |
Correct |
7 ms |
1132 KB |
Output is correct |
19 |
Correct |
10 ms |
1260 KB |
Output is correct |
20 |
Correct |
7 ms |
1132 KB |
Output is correct |
21 |
Correct |
7 ms |
1132 KB |
Output is correct |
22 |
Correct |
7 ms |
1132 KB |
Output is correct |
23 |
Correct |
7 ms |
1260 KB |
Output is correct |
24 |
Correct |
8 ms |
1132 KB |
Output is correct |
25 |
Correct |
7 ms |
1132 KB |
Output is correct |
26 |
Incorrect |
13 ms |
1896 KB |
Integer 59568 violates the range [0, 40000] |
27 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
7 ms |
1132 KB |
Output is correct |
5 |
Incorrect |
276 ms |
18616 KB |
Integer 764742 violates the range [0, 40000] |
6 |
Halted |
0 ms |
0 KB |
- |