# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
442154 | elazarkoren | Xor Sort (eJOI20_xorsort) | C++17 | 1 ms | 204 KiB |
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 <iostream>
#include <vector>
#include <algorithm>
#define x first
#define y second
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
vi a;
vii ans;
void Swap(int i, int j) {
ans.push_back({j, i});
ans.push_back({i, j});
ans.push_back({j, i});
swap(a[i], a[j]);
}
int main() {
int n, s;
cin >> n >> s;
a.resize(n);
for (int i = 0; i < n; i++) cin >> a[i];
while (true) {
bool is_new = false;
for (int i = 0; i < n - 1; i++) {
if (a[i] > a[i + 1]) {
Swap(i, i + 1);
is_new = true;
}
}
if (!is_new) break;
}
cout << ans.size() << '\n';
for (int i = 0; i < ans.size(); i++) {
cout << ans[i].x << ' ' << ans[i].y << '\n';
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |