Submission #95204

#TimeUsernameProblemLanguageResultExecution timeMemory
95204someone_aaUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
6 ms512 KiB
#include <vector> #include <bits/stdc++.h> #include "messy.h" #define pb push_back #define mp make_pair using namespace std; const int maxn = 130; bool taken[130]; string zeros; int n; void add(int l, int r) { if(l == r) return; else { int mid = (l + r) / 2; string tmp = zeros; for(int i=0;i<n;i++) { if(i < l || i > r) tmp[i] = '1'; } for(int i=l;i<=mid;i++) { tmp[i] = '1'; add_element(tmp); tmp[i] = '0'; } add(l, mid); add(mid+1, r); } } vector<int>result; bool here[maxn]; void solve(int l, int r, vector<int>possible) { if(l == r) { result[possible[0]] = l; return; } else { // for each element that is not in possible put 1 on bit searching mask int mid = (l + r) / 2; memset(here,false,sizeof(here)); string tmp = zeros; for(int i:possible) here[i] = true; vector<int>ls; vector<int>rs; for(int i=0;i<n;i++) { if(!here[i]) tmp[i] = '1'; } for(int i=0;i<n;i++) { if(here[i]) { tmp[i] = '1'; if(check_element(tmp)) { ls.pb(i); } else { rs.pb(i); } tmp[i] = '0'; } } /*cout<<"["<<l<<", "<<mid<<"] -> "; for(int i:ls) cout<<i<<" "; cout<<"\n"; cout<<"["<<mid+1<<", "<<r<<"] -> "; for(int i:rs) cout<<i<<" "; cout<<"\n";*/ solve(l, mid, ls); solve(mid+1,r, rs); } } std::vector<int> restore_permutation(int N, int w, int r) { n = N; vector<int>possible; for(int i=0;i<n;i++) { zeros += "0"; result.pb(0); possible.pb(i); } add(0, n-1); compile_set(); solve(0, n-1, possible); return result; }
#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...