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"
#define int long long
using namespace std;
const int sz = 155;
int a[sz];
signed main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n, s;
cin >> n >> s;
for (int i = 1; i <= n; i ++)
cin >> a[i];
vector<pair<int,int>> v;
for (int i = 1; i <= n; i ++)
for (int j = n-1; i <= j; j --)
if (a[j+1] < a[j]) {
v.push_back(make_pair(j, j+1));
v.push_back(make_pair(j+1, j));
v.push_back(make_pair(j, j+1));
swap(a[j], a[j+1]);
}
cout << v.size() << '\n';
for (auto& p : v)
cout << p.first << ' ' << p.second << '\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... |