Submission #598524

#TimeUsernameProblemLanguageResultExecution timeMemory
598524cheissmartUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
2 ms468 KiB
#include "messy.h" #include <bits/stdc++.h> #define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0); #define F first #define S second #define V vector #define PB push_back #define EB emplace_back #define MP make_pair #define SZ(v) int((v).size()) #define ALL(v) (v).begin(), (v).end() using namespace std; typedef long long ll; typedef pair<int, int> pi; typedef V<int> vi; const int INF = 1e9 + 7; vi restore_permutation(int n, int w, int r) { { function<void(int, int, string)> dfs = [&] (int l, int r, string s) { if(r - l == 1) return; int m = (l + r) / 2; for(int i = l; i < m; i++) { string t = s; t[i] = '1'; add_element(t); } { string t = s; for(int i = m; i < r; i++) t[i] = '1'; dfs(l, m, t); } { string t = s; for(int i = l; i < m; i++) t[i] = '1'; dfs(m, r, t); } }; dfs(0, n, string(n, '0')); } compile_set(); vi ans(n); { function<void(int, int, string, vi)> dfs = [&] (int l, int r, string s, vi x) { assert(SZ(x) == r - l); if(r - l == 1) { ans[x[0]] = l; return; } int m = (r + l) / 2; vi left, right; for(int i:x) { string t = s; t[i] = '1'; if(check_element(t)) { left.PB(i); } else { right.PB(i); } } { string t = s; for(int i:right) t[i] = '1'; dfs(l, m, t, left); } { string t = s; for(int i:left) t[i] = '1'; dfs(m, r, t, right); } }; vi tt; for(int i = 0; i < n; i++) tt.PB(i); dfs(0, n, string(n, '0'), tt); } 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...