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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define bitcount __builtin_popcountll
using namespace std;
using namespace __gnu_pbds;
using namespace chrono;
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
int n; cin >> n;
int a[n]; for (int i = 0; i < n; cin >> a[i++]);
auto oper = [&](int& x, int& y) {
x ^= y;
};
vector<pair<int,int>> operations;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) if (a[i] > a[j]) {
oper(a[i], a[j]);
oper(a[j], a[i]);
oper(a[i], a[j]);
operations.emplace_back(i, j);
operations.emplace_back(j, i);
operations.emplace_back(i, j);
}
}
cout << operations.size() << "\n";
for (auto [i, j] : operations) cout << i+1 << " " << j+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... |