Submission #278860

#TimeUsernameProblemLanguageResultExecution timeMemory
278860tinjyuUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
4 ms640 KiB
#include <vector> #include "messy.h" #include <iostream> using namespace std; int ans[100005],tag[100005],N; void add(int s,int e) { if(s==e)return ; int mid=(s+e)/2; string str=""; for(int i=0;i<N;i++)str+='0'; for(int i=0;i<s;i++)str[i]='1'; for(int i=e+1;i<N;i++)str[i]='1'; for(int i=s;i<=mid;i++) { str[i]='1'; add_element(str); str[i]='0'; } add(s,mid); add(mid+1,e); return ; } int find(int s,int e) { //cout<<s<<" "<<e<<endl; if(s==e) { for(int i=0;i<N;i++) { if(tag[i]==0)ans[i]=s; } return 0; } string str=""; for(int i=0;i<N;i++)str+='0'; for(int i=0;i<N;i++)if(tag[i]==1)str[i]='1'; int tmp[1005]; for(int i=0;i<N;i++)tmp[i]=0; for(int i=0;i<N;i++) { if(tag[i]==0) { str[i]='1'; //cout<<str<<" "; bool c=check_element(str); //cout<<c<<endl; if(c==1)tmp[i]=1; else tmp[i]=2; str[i]='0'; } } for(int i=0;i<N;i++) { if(tmp[i]==0 || tmp[i]==2)tag[i]=1; else tag[i]=0; } find(s,(s+e)/2); for(int i=0;i<N;i++) { if(tmp[i]==0 || tmp[i]==1)tag[i]=1; else tag[i]=0; } find((s+e)/2+1,e); return 0; } std::vector<int> restore_permutation(int n, int w, int r) { N=n; add(0,n-1); compile_set(); find(0,n-1); vector<int>a(n); for(int i=0;i<n;i++) { a[i]=ans[i]; } return a; }
#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...