# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
240811 | wleung_bvg | 동기화 (JOI13_synchronization) | C++17 | 199 ms | 18284 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
template<class C>constexpr int sz(const C&c){return int(c.size());}
using ll=long long;constexpr const char nl='\n',sp=' ';
template <class _Node, class Container = deque<_Node>> struct Splay {
using Node = _Node; Container TR; deque<Node*> deleted;
static_assert(Node::HAS_PAR, "Splay Node must have parent pointer");
template <class T> Node *makeNode(const T &v) {
if (deleted.empty()) { TR.emplace_back(v); return &TR.back(); }
Node *x = deleted.back(); deleted.pop_back();
*x = typename Container::value_type(v); return x;
}
bool isRoot(Node *x) { return !x->p || (x != x->p->l && x != x->p->r); }
void connect(Node *x, Node *p, bool hasCh, bool isL) {
if (x) x->p = p;
if (hasCh) (isL ? p->l : p->r) = x;
}
void rotate(Node *x) {
Node *p = x->p, *g = p->p; bool isRootP = isRoot(p), isL = x == p->l;
connect(isL ? x->r : x->l, p, true, isL); connect(p, x, true, !isL);
connect(x, g, !isRootP, !isRootP && p == g->l); p->update();
}
void splay(Node *x) {
while (!isRoot(x)) {
Node *p = x->p, *g = p->p; if (!isRoot(p)) g->propagate();
p->propagate(); x->propagate();
if (!isRoot(p)) rotate((x == p->l) == (p == g->l) ? p : x);
rotate(x);
}
# | 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... |