Submission #881956

#TimeUsernameProblemLanguageResultExecution timeMemory
881956JakobZorzUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
2 ms628 KiB
#include<vector> #include<iostream> #include"messy.h" using namespace std; string f; vector<int>get_order(vector<int>arr){ if(arr.size()==1) return arr; string str=f; for(int i:arr) str[i]='0'; vector<int>arr1,arr2; for(int i:arr){ str[i]='1'; if(check_element(str)){ arr1.push_back(i); }else{ arr2.push_back(i); } str[i]='0'; } vector<int>res1=get_order(arr1); vector<int>res2=get_order(arr2); //for(int&i:res2){ // i+=(int)res1.size(); //} res1.insert(res1.end(),res2.begin(),res2.end()); return res1; } vector<int>restore_permutation(int n,int _w,int _r){ for(int i=0;i<n;i++) f.push_back('1'); for(int p=2;p<=n;p+=p){ for(int i=0;i<n;i+=p){ string str=f; for(int j=i;j<i+p;j++){ str[j]='0'; } for(int j=i;j<i+(p/2);j++){ str[j]='1'; add_element(str); //cout<<"add: "<<str<<"\n"; str[j]='0'; } } } compile_set(); vector<int>arr(n); for(int i=0;i<n;i++) arr[i]=i; vector<int>res=get_order(arr); vector<int>res2(n); for(int i=0;i<n;i++){ res2[res[i]]=i; } return res2; }
#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...