제출 #1074465

#제출 시각아이디문제언어결과실행 시간메모리
1074465YassineBenYounesUnscrambling a Messy Bug (IOI16_messy)C++17
20 / 100
2 ms604 KiB
#include "messy.h" #include <bits/stdc++.h> using namespace std; #define vi vector<int> #define pb push_back int sz; vector<string> ask; vi res; void preprocess(int l, int r){ if(l == r)return; string s(sz, '0'); for(int i = 0; i < l;i++){ s[i] = '1'; } for(int i = r+1; i < sz;i++){ s[i] = '1'; } int md = (l+r)/2; for(int i = l;i <= md;i++){ s[i] = '1'; ask.pb(s); s[i] = '0'; } preprocess(l, md); preprocess(md+1, r); } string cur; void solve(int l, int r, set<int> possible){ if(possible.size() == 1){ res[l] = *possible.begin(); return; } set<int> left; for(int x : possible){ cur[x] = '1'; //cout << cur << endl; bool k = check_element(cur); if(k){ left.insert(x); } cur[x] = '0'; } set<int> right = possible; for(int x : left){ right.erase(x); } int md = (l+r)/2; for(int x : right){ cur[x] = '1'; } solve(l, md, left); for(int x : right){ cur[x] = '0'; } for(int x : left){ cur[x] = '1'; } solve(md+1, r, right); for(int x : left){ cur[x] = '0'; } } std::vector<int> restore_permutation(int N, int w, int r) { sz = N; preprocess(0, sz-1); for(string s: ask){ //cout << s << endl; add_element(s); } compile_set(); res.resize(sz); //cout << endl; //res = {7, 6, 5, 4, 3, 2, 1, 0}; set<int> mys; for(int i = 0; i < sz;i++){ mys.insert(i); } cur.resize(sz, '0'); solve(0, sz-1, mys); return res; }
#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...