제출 #380649

#제출 시각아이디문제언어결과실행 시간메모리
380649denkendoemeerUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
3 ms640 KiB
#include<bits/stdc++.h> #include "messy.h" using namespace std; int n; vector<int>rez; void build(int st,int dr) { if (st==dr) return ; string ans=string(n,'0'); int i; for(i=st;i<=dr;i++) ans[i]='1'; int mij=(st+dr)/2; for(i=st;i<=mij;i++){ ans[i]='0'; add_element(ans); ans[i]='1'; } build(st,mij); build(mij+1,dr); } void solve(int st,int dr,vector<int>&v) { if (st==dr){ rez[v[0]]=st; return ; } vector<int>vst,vdr; string aux=string(n,'0'); for(auto it:v) aux[it]='1'; for(auto it:v){ aux[it]='0'; if (check_element(aux)) vst.push_back(it); else vdr.push_back(it); aux[it]='1'; } int mij=(st+dr)/2; solve(st,mij,vst); solve(mij+1,dr,vdr); } vector<int> restore_permutation(int n2,int w,int r) { n=n2; vector<int>aux(n); iota(aux.begin(),aux.end(),0); rez.resize(n); build(0,n-1); compile_set(); solve(0,n-1,aux); return rez; }
#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...