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 "messy.h"
using namespace std;
vector<int> restore_permutation(int n, int w, int r) {
string s1 = "10101010", s2 = "11001100";
add_element(s1);
add_element(s2);
compile_set();
vector<int> perm(n);
for (int i = 0; i < n; i++) {
perm[i] = i;
}
bool isS1 = check_element(s1), isS2 = check_element(s2);
if (isS1 && isS2) return perm;
if (!isS1) { // swap happened between 1 and 0
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
if (s1[i] == s1[j]) continue;
swap(s1[i], s1[j]);
if (check_element(s1)) {
swap(perm[i], perm[j]);
return perm;
}
swap(s1[i], s1[j]);
}
}
} else {
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
if (s2[i] == s2[j]) continue;
swap(s2[i], s2[j]);
if (check_element(s2)) {
swap(perm[i], perm[j]);
return perm;
}
swap(s2[i], s2[j]);
}
}
}
return perm;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |