# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
464892 | bigo | Xor Sort (eJOI20_xorsort) | C++14 | 1093 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 <bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll, ll> pii;
int main() {
int s, n;
cin >> n >> s;
vector<ll>vec(n);
for (int i = 0; i < n; i++)
cin >> vec[i];
vector<pii>vec1;
vec1.push_back({ 0, 1 });
for (int i = 1; i < n - 1; i++) {
vec1.push_back({ i,i - 1 });
vec1.push_back({ i,i + 1 });
}
vec1.push_back({ n - 1,n - 2 });
bool fl = true;
for (int i = 0; i < n-1; i++) {
if (vec[i] >= vec[i + 1]) {
fl = false;
break;
}
}
if (!fl) {
int pla;
while (next_permutation(vec1.begin(), vec1.end())) {
vector<ll>tmp = vec;
bool fl2=false;
for (int i = 0; i < vec1.size(); i++) {
tmp[vec1[i].first] = (tmp[vec1[i].first] ^ tmp[vec1[i].second]);
bool fl1 = true;
for (int j = 0; j < n - 1; j++) {
if (tmp[j] >= tmp[j + 1]) {
fl1 = false;
break;
}
}
if (fl1) {
pla = i;
fl2 = true;
break;
}
}
if (fl2)
break;
}
cout << pla + 1 << endl;
for (int i = 0; i <= pla; i++)
cout << vec1[i].first + 1 << " " << vec1[i].second + 1 << endl;
}
else
cout << 0;
}
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... |