제출 #131816

#제출 시각아이디문제언어결과실행 시간메모리
131816hugo_pmUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
4 ms640 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...