Submission #934526

#TimeUsernameProblemLanguageResultExecution timeMemory
934526ByeWorldUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
2 ms852 KiB
#include <bits/stdc++.h> #define bupol __builtin_popcount #define ll long long #define ld long double #define fi first #define se second #define pb push_back #define lf (id<<1) #define rg ((id<<1)|1) using namespace std; const int MAXN = 1e3+5; const int MAXK = 205; const int LOG = 20; const int MOD = 1e9+7; const int SQRT = 520; const ll INF = 1e18+10; typedef pair<int,int> pii; typedef pair<pii,int> ipii; #include "messy.h" int nm; vector <int> vec; void binser(int l, int r){ if(l >= r) return; int md = ((l+r)>>1); string s(nm,'1'); for(int i=l; i<=r; i++) s[i] = '0'; for(int i=l; i<=md; i++){ s[i] = '1'; add_element(s); //cout << s << '\n'; s[i] = '0'; } binser(l, md); binser(md+1, r); } vector <int> pos; /* 01234567 14570236 17450326 71450362*/ void CHECK(int l, int r){ // for (int i=0;i<nm;i++) { // cout<<pos[i]; // } //cout<<endl; int md = ((l+r)>>1); if(l >= r) return; string s(nm, '1'); /* 1-----l-----m-----r-----n ------j------k-----------*/ for(int i=l; i<=r; i++) s[pos[i]] = '0'; for(int i=0,j=l,k=md+1; i<nm; i++){ if (s[i]=='1') continue; s[i] = '1'; if(check_element(s)){ //cout<<"T"; pos[j]=i; j++; } else { //cout<<"F"; pos[k]=i; k++; } s[i] = '0'; //cout<<endl; } CHECK(l, md); CHECK(md+1, r); } vector<int> restore_permutation(int N, int w, int r) { nm = N; vec.resize(nm); for(int i=0; i<nm; i++) vec[i] = -1; binser(0, nm-1); compile_set(); pos.resize(nm); for(int i=0; i<nm; i++) pos[i] = i; CHECK(0, nm-1); vector <int> ans(nm); for(int i=0; i<nm; i++) ans[pos[i]] = 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...