Submission #601099

#TimeUsernameProblemLanguageResultExecution timeMemory
601099MohamedFaresNebiliUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
2 ms468 KiB
#include <bits/stdc++.h> #include "messy.h" /// #pragma GCC optimize ("Ofast") /// #pragma GCC target ("avx2") /// #pragma GCC optimize("unroll-loops") using namespace std; using ll = long long; using ii = pair<ll, ll>; using vi = vector<int>; #define ff first #define ss second #define pb push_back #define all(x) (x).begin(), (x).end() #define lb lower_bound const int oo = 1000 * 1000 * 1000 + 7; int N; vector<int> res; void build(int l, int r) { if(l == r) return; int md = (l + r) / 2; string S(N, '1'); for(int i = l; i <= r; i++) S[i] = '0'; for(int i = l; i <= md; i++) { S[i] = '1'; add_element(S); S[i] = '0'; } build(l, (l + r) / 2); build((l + r) / 2 + 1, r); } void solve(int l, int r, vector<int> A) { if(l == r) { res[A.back()] = l; return; } string S(N, '1'); for(auto u : A) S[u] = '0'; vector<int> lo, hi; for(auto u : A) { S[u] = '1'; if(check_element(S)) lo.push_back(u); else hi.push_back(u); S[u] = '0'; } solve(l, (l + r) / 2, lo); solve((l + r) / 2 + 1, r, hi); } vector<int> restore_permutation(int n, int W, int R) { N = n; res.assign(N, -1); build(0, N - 1); compile_set(); vector<int> A(N); for(int l = 0; l < N; l++) A[l] = l; solve(0, N - 1, A); return res; }
#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...