이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <vector>
#include "messy.h"
using namespace std;
int nbBits;
vector<int> permAns;
string vide;
void preparer(int gauche, int droite)
{
if (gauche == droite) return;
string rq = vide;
for (int pos = 0; pos < nbBits; ++pos) {
rq[pos] = ((gauche <= pos && pos <= droite) ? '0' : '1');
}
int mid = (gauche + droite) / 2;
for (int pos = gauche; pos <= mid; ++pos) {
rq[pos] = '1';
fflush(stdout);
add_element(rq);
rq[pos] = '0';
}
preparer(gauche, mid);
preparer(mid+1, droite);
}
void catchMe(int gaucheBase, int droiteBase, vector<bool> estInclus)
{
if (gaucheBase == droiteBase) {
for (int pos = 0; pos < nbBits; ++pos) {
if (estInclus[pos]) {
permAns[pos] = gaucheBase;
}
}
return;
}
string rq = vide;
vector<bool> incLeft(nbBits, false);
vector<bool> incRight(nbBits, false);
for (int pos = 0; pos < nbBits; ++pos) {
rq[pos] = (estInclus[pos] ? '0' : '1');
}
for (int pos = 0; pos < nbBits; ++pos) {
if (estInclus[pos]) {
rq[pos] = '1';
bool dansSet = check_element(rq);
rq[pos] = '0';
if (dansSet) incLeft[pos] = true;
else incRight[pos] = true;
}
}
int mid = (gaucheBase+droiteBase) / 2;
catchMe(gaucheBase, mid, incLeft);
catchMe(mid+1, droiteBase, incRight);
}
std::vector<int> restore_permutation(int _n, int _w, int _r)
{
nbBits = _n;
vide.resize(nbBits);
permAns.resize(nbBits);
preparer(0, nbBits-1);
compile_set();
catchMe(0, nbBits-1, vector<bool>(nbBits, true));
return permAns;
}
# | 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... |