#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 get_node(vector<int> order) {
if (order.size() == 1) return order[0];
int res = s;
if (order.size() & 1) order.insert(order.begin(), s);
else {
fo(i, 0, order.size() / 2) {
if (order[i] != order[order.size() / 2 + i]) goto nope;
}
order.resize(order.size() / 2);
return get_node(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] = get_node(left);
y[to_overwrite] = get_node(right);
return res;
}
void create_circuit(int m, vector<int> a) {
int n = a.size();
vector<int> c(m + 1);
vector<int> t;
c[0] = a[0];
fo(i, 0, a.size()) {
t.pb(i + 1 < a.size() ? a[i + 1] : 0);
}
int res = get_node(t);
fo(i, 0, m) c[i + 1] = res;
answer(c, x, y);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |