제출 #541799

#제출 시각아이디문제언어결과실행 시간메모리
541799status_codingUnscrambling a Messy Bug (IOI16_messy)C++14
20 / 100
2 ms468 KiB
#include "messy.h" #include <bits/stdc++.h> using namespace std; string s; vector<int> ans; void genQuery(int st, int dr) { if(st == dr) return; int mij=(st+dr)/2; for(int i=st; i<=mij; i++) { s[i]='1'; //cout<<s<<'\n'; add_element(s); s[i]='0'; } for(int i=mij+1; i<=dr; i++) s[i]='1'; genQuery(st, mij); for(int i=mij+1; i<=dr; i++) s[i]='0'; for(int i=st; i<=mij; i++) s[i]='1'; genQuery(mij+1, dr); } void genAns(int st, int dr, vector<int> v) { /* cout<<st<<' '<<dr<<":\n"; for(int it : v) cout<<it<<' '; cout<<"\n\n"; */ if(st == dr) { ans[st] = v[0]; return; } int mij=(st+dr)/2; vector<int> vL, vR; for(int it : v) { s[it]='1'; //cout<<"query "<<s<<' '; if(check_element(s)) { //cout<<"da\n"; vL.push_back(it); } else { //cout<<"nu\n"; vR.push_back(it); } s[it]='0'; } //cout<<'\n'; for(int it : vR) s[it]='1'; genAns(st, mij, vL); for(int it : vR) s[it]='0'; for(int it : vL) s[it]='1'; genAns(mij+1, dr, vR); } vector<int> restore_permutation(int n, int w, int r) { s.resize(n); ans.resize(n); for(int i=0; i<n; i++) s[i]='0'; genQuery(0, n-1); compile_set(); for(int i=0; i<n; i++) s[i]='0'; vector<int> aux; for(int i=0;i<n;i++) aux.push_back(i); genAns(0, n-1, aux); return ans; } /* 16 64 64 0 1 2 3 4 5 7 8 14 11 6 9 10 12 13 15 */
#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...