# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
467882 | warner1129 | Magic Tree (CEOI19_magictree) | C++17 | 207 ms | 45868 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>
#define ff first
#define ss second
using namespace std;
struct segment_tree {
static const int maxn = 2e6 + 5;
int ls[maxn] = {}, rs[maxn] = {};
long long ma[maxn] = {}, tag[maxn] = {};
int buf = 0;
inline void updata(int p, long long v) { ma[p] += v, tag[p] += v; }
inline void pull(int p) { ma[p] = max(ma[ls[p]], ma[rs[p]]); }
inline void push(int p) {
if (!tag[p] || !p) return;
if (ls[p]) updata(ls[p], tag[p]);
if (rs[p]) updata(rs[p], tag[p]);
tag[p] = 0;
}
void add(int &p, int l, int r, int pos, long long val, long long m) {
if (!p) p = ++buf;
if (l == r) { ma[p] = val + max(m, ma[p]); return; }
push(p);
int mid = (l + r) >> 1;
if (pos <= mid) add(ls[p], l, mid, pos, val, m);
else add(rs[p], mid+1, r, pos, val, max(m, ma[ls[p]]));
pull(p);
}
void Merge(int &a, const int &b, int l, int r, long long am, long long bm) {
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |