제출 #789349

#제출 시각아이디문제언어결과실행 시간메모리
789349fatemetmhrUnscrambling a Messy Bug (IOI16_messy)C++17
20 / 100
1 ms340 KiB
// ~ Be Name Khoda ~ // #include "messy.h" #include <bits/stdc++.h> //#pragma GCC optimize ("O3") //#pragma GCC target("avx2") //#pragma GCC optimize("unroll-loops,Ofast") using namespace std; typedef long long ll; #define pb push_back #define mp make_pair #define all(x) x.begin(), x.end() #define fi first #define se second const int maxn = 1e6 + 10; const int maxn5 = 5e5 + 10; const int maxnt = 1.2e6 + 10; const int maxn3 = 1e3 + 10; const int mod = 1e9 + 7; const ll inf = 1e18; string t = "00000000"; vector <pair<pair<int, pair<int, int>>, string>> av; void build(int l, int r){ if(r - l == 1) return; int mid = (l + r) >> 1; string s = t; for(int i = l; i < mid; i++) s[i] = '1'; av.pb({{r - l, {l, r}}, s}); add_element(s); build(l, mid); build(mid, r); } std::vector<int> restore_permutation(int n, int w, int r) { build(0, n); compile_set(); sort(all(av)); vector <int> ans; for(int i = 0; i < n; i++) ans.pb(i); while(av.size()){ string s = av.back().se; int l = av.back().fi.se.fi, r = av.back().fi.se.se; int mid = (l + r) >> 1; av.pop_back(); if(check_element(s)) continue; for(int i = l; i < mid; i++) for(int j = mid; j < r; j++){ s[i] = '0'; s[j] = '1'; if(check_element(s)){ swap(ans[i], ans[j]); return ans; } s[i] = '1'; s[j] = '0'; } } 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...