This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Iterative segtree implementation makes it easy to implement yay
#include "doll.h"
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define eb(x...) emplace_back(x)
const int inf = 1e9, N = 1 << 18;
int t[N << 1], r[N];
void create_circuit(int m, vector<int> a) {
a.eb(0); int n = a.size(), sz = 1;
while (sz < n) sz <<= 1;
rep(i, 0, sz) t[i | sz] = inf;
for (int i = 0, j = 0; i < sz; ++i) {
r[i] = r[i >> 1];
if (i & 1) r[i] |= sz;
r[i] >>= 1;
if (sz - n <= r[i])
t[r[i] | sz] = a[j++];
}
int rt = 0;
vector<int> x, y;
for (int i = sz; --i; )
if (t[i << 1|0] != t[i << 1|1]) {
t[i] = --rt;
x.eb(t[i << 1|0]);
y.eb(t[i << 1|1]);
} else t[i] = t[i << 1];
rep(i, 0, -rt) {
if (x[i] == inf) x[i] = rt;
if (y[i] == inf) y[i] = rt;
}
answer(vector<int>(m + 1, rt), 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... |