Submission #599155

#TimeUsernameProblemLanguageResultExecution timeMemory
599155PyishtellUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
3 ms592 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #include "messy.h" int n; vector<int> v; void dfs(vector<int> x, vector<int> y){ if(x.size()==2){ bool b = check_element(string(n-1,'1').insert(y[1],"0")); if(b) v[x[0]] = y[0], v[x[1]] = y[1]; else v[x[0]] = y[1], v[x[1]] = y[0]; } else{ int gap = x.size(); vector<int> x1, x2, y1, y2; for(int i=0; i<gap; i++){ string s = string(n-gap,'1'); for(int j=0; j<gap; j++){ if(j==i) s.insert(y[j],"1"); else s.insert(y[j],"0"); } bool b = check_element(s); if(b) y1.push_back(y[i]); else y2.push_back(y[i]); } for(int i=0; i<gap; i++){ if(i<gap/2) x1.push_back(x[i]); else x2.push_back(x[i]); } dfs(x1, y1); dfs(x2, y2); } return; } std::vector<int> restore_permutation(int nn, int w, int r) { n = nn; v.resize(n); for(int i=n; i>1; i/=2){ for(int j=1; j<=n; j+=i){ for(int k=0; k<i/2; k++){ add_element(string(j-1,'1')+string(i-1,'0').insert(k,"1")+string(n-i-j+1,'1')); } } } compile_set(); vector<int> x(n), y(n); for(int i=0; i<n; i++) x[i]=i, y[i]=i; dfs(x, y); vector<int> vv(n); for(int i=0; i<n; i++){ vv[v[i]] = i; } return vv; }
#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...