제출 #131223

#제출 시각아이디문제언어결과실행 시간메모리
131223mahmoudbadawyUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
4 ms508 KiB
#include <vector> #include "messy.h" #include <bits/stdc++.h> using namespace std; int ans[200]; int n; void build(int l,int r) { if(l==r||r<l) return; string s=string(n,'1'); for(int i=l;i<=r;i++) s[i]='0'; int mid=(l+r)/2; for(int i=l;i<=mid;i++) { s[i]='1'; add_element(s); s[i]='0'; } build(l,mid); build(mid+1,r); } void solve(int l,int r,vector<int> ind) { /*cout << l << " " << r << " : "; for(int i:ind) cout << i << " "; cout << endl;*/ if(l==r) { ans[ind[0]]=l; return; } vector<int> ll,rr; string s=string(n,'1'); for(int i:ind) s[i]='0'; for(int i:ind) { s[i]='1'; //cout << s << endl; if(check_element(s)) ll.push_back(i); else rr.push_back(i); s[i]='0'; } int mid=(l+r)/2; solve(l,mid,ll); solve(mid+1,r,rr); } std::vector<int> restore_permutation(int nn, int w, int r) { /*add_element("0"); compile_set(); check_element("0"); return std::vector<int>();*/ n=nn; //cout << "OK" << endl; build(0,n-1); //cout << "OK" << endl; compile_set(); //cout << "OK" << endl; vector<int> v; for(int i=0;i<n;i++) v.push_back(i); solve(0,n-1,v); vector<int> ret; for(int i=0;i<n;i++) ret.push_back(ans[i]); //for(int i:ret) cout << i << " "; cout << endl; return ret; }
#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...