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;
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define fi first
#define se second
int n, type;
vector<int> val;
vector<pii > ans;
void doSwap(int i, int j) {
ans.pb(mp(i, j));
ans.pb(mp(j, i));
ans.pb(mp(i, j));
swap(val[i], val[j]);
}
void solve1() {
val.assign(1 + n, 0);
for(int i = 1; i <= n; ++i) cin >> val[i];
for(int i = n; i > 1; --i) {
for(int j = 1; j < i; ++j) {
if(val[j] > val[j + 1]) {
doSwap(j, j + 1);
}
}
}
cout << ans.size() << "\n";
for(pii p : ans) {
cout << p.fi << " " << p.se << "\n";
}
}
void solve() {
cin >> n >> type;
if(n <= 150 && type == 1) solve1();
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |