Submission #434442

#TimeUsernameProblemLanguageResultExecution timeMemory
434442vanicUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
3 ms480 KiB
#include <vector> #include "messy.h" #include <iostream> #include <algorithm> #include <cmath> using namespace std; vector < int > sol; void pitaj(string s, int l, int d){ if(l+1==d){ return; } // cout << l << ' ' << d << endl; int mid=(l+d)/2; for(int i=l; i<mid; i++){ s[i]='1'; add_element(s); s[i]='0'; } for(int i=mid; i<d; i++){ s[i]='1'; } pitaj(s, l, mid); for(int i=mid; i<d; i++){ s[i]='0'; } for(int i=l; i<mid; i++){ s[i]='1'; } pitaj(s, mid, d); } void rijesi(string s, vector < int > v, int br){ if(br==1){ sol.push_back(v[0]); return; } vector < int > v1, v2; for(int i=0; i<br; i++){ s[v[i]]='1'; if(check_element(s)){ v1.push_back(v[i]); } else{ v2.push_back(v[i]); } s[v[i]]='0'; } for(int i=0; i<br/2; i++){ s[v2[i]]='1'; } rijesi(s, v1, br/2); for(int i=0; i<br/2; i++){ s[v2[i]]='0'; } for(int i=0; i<br/2; i++){ s[v1[i]]='1'; } rijesi(s, v2, br/2); } vector < int > kraj; vector < int > restore_permutation(int n, int w, int r){ string s; for(int i=0; i<n; i++){ s.push_back('0'); } pitaj(s, 0, n); compile_set(); vector < int > v; for(int i=0; i<n; i++){ v.push_back(i); } rijesi(s, v, n); kraj.resize(n, 0); for(int i=0; i<n; i++){ kraj[sol[i]]=i; } return kraj; }
#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...