Submission #731320

#TimeUsernameProblemLanguageResultExecution timeMemory
731320senthetaUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms468 KiB
#include "messy.h" // author : sentheta aka vanwij #include<iostream> #include<iomanip> #include<algorithm> #include<cassert> #include<random> #include<chrono> #include<cmath> #include<string> #include<vector> #include<bitset> #include<queue> #include<stack> #include<map> #include<set> using namespace std; #define Int long long #define V vector #define pii pair<int,int> #define ff first #define ss second mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); #define pow2(x) (1LL<<(x)) #define msb(x) (63-__builtin_clzll(x)) #define bitcnt(x) (__builtin_popcountll(x)) #define nl '\n' #define _ << ' ' << #define all(x) (x).begin(), (x).end() #define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++) #define dbg(x) if(1) cout << "?" << #x << " : " << (x) << endl << flush; int n; V<int> ans; #define mid (l+r)/2 void build(int l,int r){ if(l==r) return; string s = string(n,'1'); rep(i,l,r+1){ s[i] = '0'; } rep(i,l,mid+1){ s[i] = '1'; add_element(s); s[i] = '0'; } build(l,mid); build(mid+1,r); } // v = answer in this segment void solve(int l,int r,V<int> v){ if(l==r){ ans[v[0]] = l; return; } string s = string(n,'1'); for(int i : v){ s[i] = '0'; } V<int> lv, rv; for(int i : v){ s[i] = '1'; if(check_element(s)){ lv.push_back(i); } else{ rv.push_back(i); } s[i] = '0'; } solve(l,mid, lv); solve(mid+1,r, rv); } V<int> restore_permutation(int _n,int _w,int _r){ n = _n; build(0,n-1); compile_set(); ans = V<int>(n,-1); V<int> v; rep(i,0,n) v.push_back(i); solve(0,n-1,v); return ans; add_element("0"); compile_set(); check_element("0"); return V<int>(); }
#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...