제출 #66964

#제출 시각아이디문제언어결과실행 시간메모리
66964fallingstarUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
3 ms512 KiB
#include <vector> #include "messy.h" #include <string> using namespace std; // [l..r) void Add(int l, int r, string base) { if (l + 1 == r) return; int mid = (l + r) / 2; for (int i = l; i < mid; ++i) { base[i] = '1'; add_element(base.c_str()); base[i] = '0'; } // fill one side, recurse in other side fill(base.begin() + l, base.begin() + mid, '1'); Add(mid, r, base); fill(base.begin() + l, base.begin() + mid, '0'); fill(base.begin() + mid, base.begin() + r, '1'); Add(l, mid, base); } vector<int> ans; void Solve(int l, int r, vector<int> miss, string base) { if (l + 1 == r) { ans[miss[0]] = l; return; } vector<int> grL, grR; for (int x: miss) { base[x] = '1'; if (check_element(base.c_str())) grL.push_back(x); else grR.push_back(x); base[x] = '0'; } int mid = (l + r) / 2; // fill one side, recurse in other side for (int x: grR) base[x] = '1'; Solve(l, mid, grL, base); for (int x: grR) base[x] = '0'; for (int x: grL) base[x] = '1'; Solve(mid, r, grR, base); } vector<int> restore_permutation(int n, int w, int r) { Add(0, n, string(n, '0')); compile_set(); ans.resize(n); vector<int> all; for (int i = 0; i < n; ++i) all.push_back(i); Solve(0, n, all, string(n, '0')); return ans; }
#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...