Submission #207281

#TimeUsernameProblemLanguageResultExecution timeMemory
207281autumn_eelUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
7 ms508 KiB
#include "messy.h" #include <bits/stdc++.h> #define rep(i,n)for(int i=0;i<(n);i++) using namespace std; typedef pair<int,int>P; int N; void add(int l,int r){ if(r-l==1)return; int md=(l+r)/2; string s(N,'0'); for(int i=l;i<r;i++)s[i]='1'; for(int i=l;i<md;i++){ s[i]='0'; add_element(s); s[i]='1'; } add(l,md); add(md,r); } vector<int>u; void solve(vector<int>v){ if(v.size()==1)return; string s(N,'0'); for(int i:v)s[i]='1'; int add=v.size()/2; vector<int>a,b; for(int i:v){ s[i]='0'; if(check_element(s))a.push_back(i); else b.push_back(i),u[i]+=add; s[i]='1'; } solve(a);solve(b); } vector<int> restore_permutation(int n, int w, int r) { N=n; add(0,N); compile_set(); vector<int>v(n); rep(i,n)v[i]=i; u=vector<int>(n); solve(v); return u; }
#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...