This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=1e3+7;
int T[LIM], n;
vector<pair<int,int>>V;
void solve1() {
rep(i, n-1) V.pb({i+1, i});
rep(i, n) for(int j=i; j>0; --j) if(T[j-1]>T[j]) {
V.pb({j-1, j});
if(j-1>0) V.pb({j-1, j-2});
}
for(int i=n-2; i>=0; --i) V.pb({i+1, i});
}
void solve2() {
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int s;
cin >> n >> s;
rep(i, n) cin >> T[i];
if(s==1) solve1();
else solve2();
cout << V.size() << '\n';
for(auto i : V) cout << i.st+1 << " " << i.nd+1 << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |