# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
133815 | osaaateiasavtnl | Cats or Dogs (JOI18_catdog) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define ii pair <int, int>
#define app push_back
mt19937 rnd(228);
struct Node {
int x, y, cnt;
Node *l, *r;
Node (int x_) {
x = x_; y = rnd();
l = r = NULL;
cnt = 1;
}
};
int cnt(Node *t) {
if (!t) return 0;
else return t->cnt;
}
void relax(Node *t) {
t->cnt = cnt(t->l) + cnt(t->r) + 1;
}
Node *merge(Node *l, Node *r) {
if (!l) return r;
if (!r) return l;
if (l->y < r->y) {
l->r = merge(l->r, r);
relax(l);
return l;
}
else {