Submission #1022982

#TimeUsernameProblemLanguageResultExecution timeMemory
1022982parsadox2Unscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms604 KiB
#include <vector> #include "messy.h" #include <bits/stdc++.h> using namespace std; const int N = 130; int n; vector <int> p; void Add(int l , int r) { if(r - l == 1) return; string s; for(int i = 0 ; i < n ; i++) s.push_back('0'); for(int i = 0 ; i < l ; i++) s[i] = '1'; for(int i = r ; i < n ; i++) s[i] = '1'; int mid = (l + r) >> 1; for(int i = l ; i < mid ; i++) { s[i] = '1'; add_element(s); s[i] = '0'; } Add(l , mid); Add(mid , r); } void Solve(vector <int> vec , int l , int r) { if(r - l == 1) { p[vec[0]] = l; return; } int mid = (l + r) >> 1; string s; for(int i = 0 ; i < n ; i++) s.push_back('1'); for(auto u : vec) s[u] = '0'; vector <int> L , R; for(auto u : vec) { s[u] = '1'; if(check_element(s)) L.push_back(u); else R.push_back(u); s[u] = '0'; } Solve(L , l , mid); Solve(R , mid , r); } vector<int> restore_permutation(int nn, int w, int r) { n = nn; p.resize(n); Add(0 , n); compile_set(); vector <int> vec; for(int i = 0 ; i < n ; i++) vec.push_back(i); Solve(vec , 0 , n); return p; }
#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...