이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
ostream& operator<<(ostream &out, string str) {
for(char c : str) out << c;
return out;
}
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
return out << "(" << p.ST << ", " << p.ND << ")";
}
template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
out << "{";
for(auto it = a.begin(); it != a.end(); it = next(it))
out << (it != a.begin() ? ", " : "") << *it;
return out << "}";
}
void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
cerr << a << ", ";
dump(x...);
}
#ifdef DEBUG
# define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
# define debug(...) false
#endif
template<class T> int size(T && a) { return (int) a.size(); }
using LL = long long;
using PII = pair<int, int>;
#include "doll.h"
void create_circuit(int M, vector<int> A) {
A.emplace_back(0);
int dep = 0;
while((1 << dep) < size(A))
dep++;
reverse(A.begin(), A.end());
vector<int> x, y;
auto construct = [&](auto self, int d, vector<int> t) {
if(size(t) == 0) return -1;
if(d == 0) return t[0];
x.emplace_back(), y.emplace_back();
int v = size(x) - 1;
int q = min(1 << (d - 1), size(t));
vector<int> l, r;
REP(i, size(t)) {
if(i % 2 == 1 && size(l) < size(t) - q)
l.emplace_back(t[i]);
else
r.emplace_back(t[i]);
}
x[v] = self(self, d - 1, l);
y[v] = self(self, d - 1, r);
return -(v + 1);
};
construct(construct, dep, A);
answer(vector<int>(M + 1, -1), 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... |