# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
457986 | RaresFelix | Xor Sort (eJOI20_xorsort) | C++17 | 12 ms | 4680 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 <bits/stdc++.h>
#define MN 10071
#define ML 20
using namespace std;
int n, s, A[MN];
int F[(1<<21)];
vector<pair<int, int> > SOL;
void xo(int a, int b) {
--F[A[a]];
A[a] ^= A[b];
++F[A[a]];
SOL.push_back({a, b});
}
int main() {
cin >> n >> s;
for(int i = 1; i <= n; ++i)
cin >> A[i];
if(s == 1 || n <= ML){
for(int i = 1; i <= n; ++i)
for(int j = n; j >= 2; --j)
if(A[j] < A[j-1]){
if(F[A[j] ^ A[j-1]] || (A[j] ^ A[j-1]) > A[j]){
xo(j, j-1);
xo(j-1, j);
xo(j, j-1);
}
else {
xo(j-1, j);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |