제출 #1273387

#제출 시각아이디문제언어결과실행 시간메모리
1273387BlockOG자동 인형 (IOI18_doll)C++20
100 / 100
200 ms17424 KiB
#include <bits/stdc++.h> // mrrrow meeow :3 // go play vivid/stasis now! https://vividstasis.gay #define fo(i, a, b) for (auto i = (a); i < (b); i++) #define of(i, a, b) for (auto i = (b); i-- > (a);) #define f first #define s second #define pb push_back #define pob pop_back #define lb lower_bound #define ub upper_bound #define be(a) a.begin(), a.end() using namespace std; int ____init = [] { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); return 0; }(); void answer(vector<int> c, vector<int> x, vector<int> y); int s = -1; vector<int> x, y; int recurse(vector<int> order) { if (order.size() == 1) return order[0]; int res = s; fo(i, 0, order.size() / 2) { if (order[i] != order[order.size() / 2 + i]) goto nope; } order.resize(order.size() / 2); return recurse(order); nope:; s--; int to_overwrite = x.size(); x.pb(0), y.pb(0); vector<int> left, right; fo(i, 0, order.size()) { if (i & 1) right.pb(order[i]); else left.pb(order[i]); } x[to_overwrite] = recurse(left); y[to_overwrite] = recurse(right); return res; } void create_circuit(int m, vector<int> a) { int n = a.size(); a.pb(0); map<int, int> amap; fo(i, 0, n) { if (amap.count(a[i]) && amap[a[i]] != a[i + 1]) amap[a[i]] = -1; else amap[a[i]] = a[i + 1]; } vector<int> t; fo(i, 0, n) { if (amap[a[i]] == -1) t.pb(a[i + 1]); } if (t.size()) { int thing = 0; while (__builtin_popcount(thing + t.size()) > 1) thing++; vector<pair<int, int>> t2; fo(i, 0, thing) { int j = 0, k = i; fo(_, 0, 31) j = j*2 + (k&1), k /= 2; t2.pb({j, -1}); } fo(i, thing, thing + t.size()) { int j = 0, k = i; fo(_, 0, 31) j = j*2 + (k&1), k /= 2; t2.pb({j, 0}); } sort(be(t2)); vector<int> t3; for (auto [_, v] : t2) t3.pb(v); int i = 0; fo(j, 0, t.size()) { while (t3[i] == -1) i++; t3[i++] = t[j]; } recurse(t3); } vector<int> c(m + 1); c[0] = a[0]; fo(i, 0, m) c[i + 1] = amap[i + 1]; answer(c, x, y); }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...