Submission #30627

#TimeUsernameProblemLanguageResultExecution timeMemory
30627samir_droubiUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
7 ms512 KiB
#include <vector> #include "messy.h" #include <bits/stdc++.h> using namespace std; int m; int bl[200]; int br[200]; void divide(int l,int r) { if( l == r)return; string s=""; for(int i = 0 ; i < m ; ++i) s+='1'; for(int i = l ; i <= r; ++i) s[i] = '0'; int md = ( l + r ) / 2 ; for(int i = l ; i <= md ; ++i) { s[i] = '1'; add_element(s); s[i] = '0'; } divide( l , md ); divide( md + 1 , r ); } void divide1(int l,int r) { if( l == r)return; string s=""; for(int i = 0 ; i < m ; ++i) s+='0'; for(int i = 0 ; i < m ; ++i) { if(bl[i] > r) s[i] = '1'; if(br[i] < l) s[i] = '1'; } int md = ( l + r ) / 2 ; for(int i = 0 ; i < m ; ++i) { if(s[i] == '1')continue; s[i] = '1'; if(check_element(s)) { bl[i] = l; br[i] = md; } else { bl[i] = md + 1; br[i] = r; } s[i] = '0'; } divide1( l , md ); divide1( md + 1 , r ); } std::vector<int> restore_permutation(int n, int w, int r) { m = n; divide( 0 , m - 1 ); compile_set(); divide1( 0 , m - 1 ); vector<int>ans; for(int i = 0 ; i < m ; ++i) ans.push_back(bl[i]); return ans; }
#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...