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 "messy.h"
#include <bits/stdc++.h>
using namespace std;
#define form2(i, a, b) for (int i = (a); i < (b); ++i)
#define ford2(i, a, b) for (int i = (a-1); i >= b; --i)
#define form(i, n) form2(i, 0, n)
#define ford(i, n) ford2(i, n, 0)
#define chmax(x, v) x = max(x, (v))
#define chmin(x, v) x = min(x, (v))
#define fi first
#define se second
const int INF = (int)(1e9);
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
int nbElem, nbAdd, nbCheck;
pii st1()
{
string s = "00000000";
add_element(s);
form(i, nbElem) {
s[i] = '1';
add_element(s);
}
compile_set();
s = "00000000";
int rf = -1;
form(i, nbElem) {
s[i] = '1';
if (! check_element(s)) { s[i] = '0'; rf = i; break; }
}
if (rf == -1) return {-1,-1};
form2(i, rf+1, nbElem) {
s[i] = '1';
if (check_element(s)) { return {rf,i}; }
s[i] = '0';
}
return {-1,-1};
}
vector<int> restore_permutation(int n, int w, int r) {
nbElem = n;
nbAdd = w;
nbCheck = r;
vector<int> p(n);
form(i, n) p[i] = i;
if (n == 8) {
pii sw = st1();
if (sw.fi != -1) {
p[sw.fi] = sw.se;
p[sw.se] = sw.fi;
}
}
return p;
}
# | 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... |