제출 #217547

#제출 시각아이디문제언어결과실행 시간메모리
217547anonymousUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
8 ms640 KiB
#include <vector> #include<string> #include "messy.h" using namespace std; int N; vector<int> Ans; void add(int l, int r) { if (l == r) {return;} string s; int mid = (l + r) >> 1; for (int i=0; i<N; i++) { if (l <= i && i <= r) { s.push_back('0'); } else { s.push_back('1'); } } for (int i=l; i<=mid; i++) { s[i] = '1'; add_element(s); s[i] = '0'; } add(l, mid); add(mid+1,r); } void slv(int l, int r, vector<bool> Not) { if (l == r) { for (int i=0; i<N; i++) { if (!Not[i]) {Ans[i]=l;} } } else { string s; vector<bool> NotL=Not, NotR=Not; int mid = (l + r) >> 1; for (int i=0; i<N; i++) { if (Not[i]) { s.push_back('1'); } else { s.push_back('0'); } } for (int i=0; i<N; i++) { if (!Not[i]) { s[i] = '1'; if (check_element(s)) { NotR[i] = true; } else { NotL[i] = true; } s[i] = '0'; } } slv(l, mid, NotL); slv(mid+1, r, NotR); } } vector<int> restore_permutation(int n, int w, int r) { N = n; vector<bool> Not; for (int i=0; i<N; i++) { Not.push_back(0); Ans.push_back(0); } add(0, N-1); compile_set(); slv(0, N-1, Not); 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...