# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
330284 | dolphingarlic | Matryoshka (JOI16_matryoshka) | C++14 | 643 ms | 133484 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
struct Node {
int l, r, val;
Node *lc, *rc;
Node(int L, int R): l(L), r(R), val(0), lc(nullptr), rc(nullptr) {}
void update(int p, int v) {
val = max(val, v);
if (l != r) {
int mid = (l + r) / 2;
if (p > mid) {
if (!rc) rc = new Node(mid + 1, r);
rc->update(p, v);
} else {
if (!lc) lc = new Node(l, mid);
lc->update(p, v);
}
}
}
int query(int a, int b) {
if (r < a || l > b) return 0;
if (r <= b && l >= a) return val;
int ret = 0;
if (lc) ret = max(ret, lc->query(a, b));
if (rc) ret = max(ret, rc->query(a, b));
Compilation message (stderr)
# | 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... |