Submission #308475

#TimeUsernameProblemLanguageResultExecution timeMemory
308475juggernautUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
3 ms512 KiB
#include"messy.h" #include<bits/stdc++.h> //#include"grader.cpp" using namespace std; int nn; vector<int>res; void build(int l,int r){ if(l==r)return; int mid=(l+r)>>1,i=l; string s(nn,'0'); for(;i<=r;i++)s[i]='1'; for(i=l;i<=mid;i++){ s[i]='0'; add_element(s); s[i]='1'; } build(l,mid); build(mid+1,r); } void go(vector<int>v){ if(v.size()==1)return; string s(nn,'0'); for(int to:v)s[to]='1'; int mid=int(v.size())>>1; vector<int>a,b; for(int to:v){ s[to]='0'; if(check_element(s))a.push_back(to); else b.push_back(to),res[to]+=mid; s[to]='1'; } go(a); go(b); } vector<int>restore_permutation(int N,int w,int r){ nn=N; build(0,nn-1); compile_set(); res.resize(nn); vector<int>v(nn); iota(v.begin(),v.end(),0); go(v); 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...