제출 #306823

#제출 시각아이디문제언어결과실행 시간메모리
306823syyUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
3 ms512 KiB
#include "messy.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++) #define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--) typedef pair<int, int> pi; typedef pair<pi, int> pii; typedef pair<pi, pi> pipi; #define f first #define s second typedef vector<int> vi; typedef vector<pi> vpi; typedef vector<pii> vpii; #define pb push_back #define pf push_front #define all(v) v.begin(), v.end() #define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin()); #define INF (int) 1e9 + 100 #define LLINF (ll) 1e18 #define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define sandybridge __attribute__((optimize("Ofast"), target("arch=sandybridge"))) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //can be used by calling rng() or shuffle(A, A+n, rng) inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss int n; vi ans; void query(int s, int e) { string str = string(n, ' '); FOR(i, 0, n-1) str[i] = ((s <= i and i <= e) ? '0' : '1'); int m = (s+e)/2; FOR(i, s, m) { str[i] = '1'; add_element(str); str[i] = '0'; } if (s != e) { query(s, m); query(m+1, e); } } void f(int s, int e, vi v) { if (s == e) { ans[v[0]] = s; return; } string str = string(n, '1'); for (auto it:v) str[it] = '0'; vi l, r; for (auto it:v) { str[it] = '1'; (check_element(str) ? l : r).pb(it); str[it] = '0'; } int m = (s+e)/2; f(s, m, l); f(m+1, e, r); } vector<int> restore_permutation(int N, int w, int r) { n = N; ans.resize(n); vi v(n); FOR(i, 0, n-1) v[i] = i; query(0, n-1); compile_set(); f(0, n-1, v); 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...