#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(ll a = 0; a < (b); ++a)
#define lg(a) (!a?0:64-__builtin_clzll(a))
#define st first
#define nd second
#define pb push_back
const ll LIM=1e3+7;
ll T[LIM], n, s;
vector<pair<ll,ll>>ans;
void s1() {
for(ll i=n-1; i>=0; --i) {
rep(j, i+1) ans.pb({j, j+1});
ll ma=0, l=0;
rep(j, i+1) ma=max(ma, T[j]);
T[i]=ma;
while(T[l]!=ma) ++l;
for(ll j=l-2; j>=0; --j) ans.pb({j, j+1});
for(ll j=l+1; j<=i; ++j) ans.pb({j, j-1});
while(l<i) {
T[l]=T[l+1];
++l;
}
}
}
void s2() {
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> s;
rep(i, n) cin >> T[i];
//if(s==1) s1(); else s2();
s1();
cout << ans.size() << '\n';
for(auto i : ans) cout << i.st+1 << " " << i.nd+1 << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Integer 6 violates the range [1, 5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Integer 6 violates the range [1, 5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Integer 6 violates the range [1, 5] |
2 |
Halted |
0 ms |
0 KB |
- |