제출 #961900

#제출 시각아이디문제언어결과실행 시간메모리
961900ThegeekKnight16Unscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms612 KiB
#include <bits/stdc++.h> #include <vector> #include "messy.h" using namespace std; // add_element("0"); // compile_set(); // check_element("0"); void dcBuild(int ini, int fim, int N) { if (ini == fim) return; string resp(N, '0'); for (int i = 0; i < N; i++) if (i < ini || i > fim) resp[i] = '1'; int m = (ini + fim)>>1; for (int j = m+1; j <= fim; j++) { resp[j] = '1'; add_element(resp); resp[j] = '0'; } dcBuild(ini, m, N); dcBuild(m+1, fim, N); } void dcResp(int path, vector<int> &p, const vector<int> &sameBit, const vector<int> &otherBit, int N) { if (sameBit.size() == 1) {p[sameBit.back()] = path; return;} string resp(N, '0'); for (auto x : otherBit) resp[x] = '1'; vector<int> lSame, lOther = otherBit, rSame, rOther = otherBit; for (auto x : sameBit) { resp[x] = '1'; if (check_element(resp)) lOther.push_back(x), rSame.push_back(x); else lSame.push_back(x), rOther.push_back(x); resp[x] = '0'; } dcResp((path<<1)+0, p, lSame, lOther, N); dcResp((path<<1)+1, p, rSame, rOther, N); } vector<int> restore_permutation(int N, int W, int R) { dcBuild(0, N-1, N); compile_set(); vector<int> p(N), sameBit(N), otherBit; iota(sameBit.begin(), sameBit.end(), 0); dcResp(0, p, sameBit, otherBit, N); return p; }
#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...