//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("bmi,bmi2,lzcnt,popcnt")
//#pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
//#pragma expected_value
//#pragma isolated_call
//#pragma disjoint
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
//#define int long long
//#define double long double
#define Fi first
#define Se second
#define Rep(i,a,b) for (int i=a;i<=b;++i)
#define Repu(i,b,a) for (int i=b;i>=a;--i)
#define pb push_back
#define ms(a,i) memset(a,i,sizeof(a))
#define sz size()
#define mp make_pair
#define endl '\n'
#define sef setprecision(6)<<fixed
#define cer cout<<"cak"<<endl;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<double> va;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<va> vva;
//const double EPS=1e-9;
const double PI=acos(-1);
const long long oo=1e18;
const int MN=2e5+5;
const int mod=1e9+7;
using cd=complex<double>;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> index_set;
int n,s;
int a[1005];
vii ans;
int check() {
Rep(i,1,n-1) if(a[i]>=a[i+1]) return i;
return 0;
}
signed main() {
//freopen(".inp","r",stdin); freopen(".out","w",stdout);
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n>>s;
Rep(i,1,n) cin>>a[i];
int temp=check();
while(temp) {
ans.pb({temp,temp+1});
ans.pb({temp+1,temp});
ans.pb({temp,temp+1});
swap(a[temp], a[temp+1]);
temp=check();
}
cout<<ans.sz<<endl;
for(ii itr:ans) cout<<itr.Fi<<' '<<itr.Se<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
596 KB |
Output is correct |
5 |
Correct |
3 ms |
600 KB |
Output is correct |
6 |
Correct |
5 ms |
708 KB |
Output is correct |
7 |
Correct |
3 ms |
600 KB |
Output is correct |
8 |
Correct |
3 ms |
724 KB |
Output is correct |
9 |
Correct |
3 ms |
728 KB |
Output is correct |
10 |
Correct |
3 ms |
704 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
5 ms |
984 KB |
Output is correct |
13 |
Correct |
5 ms |
916 KB |
Output is correct |
14 |
Correct |
5 ms |
964 KB |
Output is correct |
15 |
Correct |
8 ms |
856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
596 KB |
Output is correct |
5 |
Correct |
3 ms |
600 KB |
Output is correct |
6 |
Correct |
5 ms |
708 KB |
Output is correct |
7 |
Correct |
3 ms |
600 KB |
Output is correct |
8 |
Correct |
3 ms |
724 KB |
Output is correct |
9 |
Correct |
3 ms |
728 KB |
Output is correct |
10 |
Correct |
3 ms |
704 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
5 ms |
984 KB |
Output is correct |
13 |
Correct |
5 ms |
916 KB |
Output is correct |
14 |
Correct |
5 ms |
964 KB |
Output is correct |
15 |
Correct |
8 ms |
856 KB |
Output is correct |
16 |
Correct |
1 ms |
324 KB |
Output is correct |
17 |
Correct |
4 ms |
600 KB |
Output is correct |
18 |
Correct |
5 ms |
840 KB |
Output is correct |
19 |
Correct |
4 ms |
856 KB |
Output is correct |
20 |
Correct |
4 ms |
856 KB |
Output is correct |
21 |
Correct |
7 ms |
836 KB |
Output is correct |
22 |
Correct |
5 ms |
856 KB |
Output is correct |
23 |
Correct |
5 ms |
856 KB |
Output is correct |
24 |
Correct |
4 ms |
856 KB |
Output is correct |
25 |
Correct |
4 ms |
868 KB |
Output is correct |
26 |
Incorrect |
8 ms |
1236 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 |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
5 ms |
856 KB |
Output is correct |
5 |
Incorrect |
187 ms |
12540 KB |
Integer 764742 violates the range [0, 40000] |
6 |
Halted |
0 ms |
0 KB |
- |