Submission #854676

#TimeUsernameProblemLanguageResultExecution timeMemory
854676sunwukong123Unscrambling a Messy Bug (IOI16_messy)C++14
70 / 100
2 ms856 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; void debug_out() {cerr<<endl;} template <typename Head, typename... Tail> void debug_out(Head _H, Tail... _T) {cerr<<" "<<to_string(_H);debug_out(_T...);} #define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__) const int MAXN =1005; const int inf=1000000500ll; const int MOD = (int)1e9 + 7; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); typedef pair<int,int> pi; int out[MAXN]; int n; void send(vector<int>&on){ string s(n,'0'); for(auto x:on)s[x]='1'; add_element(s); } set<int> s; void dnc(int st, int en,vector<int> pre){ if(st==en){ return; } int mi=(st+en)/2; for(int i=mi+1;i<=en;i++){ pre.push_back(i);send(pre); pre.pop_back(); } pre.push_back(mi+1-st); dnc(st,mi,pre); dnc(mi+1,en,pre); } int div(int n){ int r=0; while(n>1){ n/=2; r++; } return r; } vector<int> restore_permutation(int n, int w, int r) { ::n=n; int m=div(n); for(int i=2;i<n;i++){ if(__builtin_popcount(i) == 1){ string str(n,'1'); str[i]='0'; add_element(str); } } vector<int>vec; dnc(0,n-1,vec); compile_set(); set<int> impt; for(int i=0;i<n;i++){ string str(n,'1'); str[i]='0'; if(check_element(str))impt.insert(i); } vector<int> pref; for(int b=m-1;b>=0;b--){ int nb=-1; for(int i=0;i<n;i++){ string str(n,'0'); for(auto x:pref)str[x]='1'; if(str[i] == '1')continue; str[i]='1'; if(check_element(str)){ if(impt.find(i)!=impt.end()){ assert(nb==-1); nb=i; } out[i]+=1<<b; } } pref.push_back(nb); } vector<int>ans; for(int i=0;i<n;i++){ ans.push_back(out[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...