제출 #1038319

#제출 시각아이디문제언어결과실행 시간메모리
1038319Alihan_8Unscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms856 KiB
#include <vector> #include "messy.h" #include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define ar array #define pb push_back #define ln '\n' //#define int long long using i64 = long long; template <class F, class _S> bool chmin(F &u, const _S &v){ bool flag = false; if ( u > v ){ u = v; flag |= true; } return flag; } template <class F, class _S> bool chmax(F &u, const _S &v){ bool flag = false; if ( u < v ){ u = v; flag |= true; } return flag; } std::vector<int> restore_permutation(int n, int w, int r) { int b = __lg(n); for ( int i = b; i > 0; i-- ){ int k = 1 << i; for ( int j = 0; j < n; j += k ){ string s = string(n, '0'); for ( int t = j; t < j + k; t++ ){ s[t] = '1'; } for ( int t = j; t < j + k / 2; t++ ){ s[t] = '0'; add_element(s); s[t] = '1'; } } } compile_set(); vector <int> ans(n); auto dfs = [&](auto dfs, int l, int r, auto p) -> void{ if ( l == r ){ ans[p[0]] = l; return; } string s = string(n, '0'); for ( auto &x: p ){ s[x] = '1'; } vector <int> L, R; for ( auto &x: p ){ s[x] = '0'; if ( check_element(s) ){ L.pb(x); } else R.pb(x); s[x] = '1'; } int m = (l + r) / 2; dfs(dfs, l, m, L), dfs(dfs, m + 1, r, R); }; vector <int> p(n); iota(all(p), 0); dfs(dfs, 0, n - 1, p); 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...