# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1141324 | yytsi | Monkey and Apple-trees (IZhO12_apple) | C++17 | 400 ms | 327680 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int q;
ll c;
struct node {
ll l, r, value, lazy;
node *left, *right;
node(ll l, ll r) : l(l), r(r), value(0), lazy(0), left(nullptr), right(nullptr) {}
void pushLazy() {
if (lazy == 0) return;
// lazy must be applied to this node
// and then pushed to children
value = (r - l + 1);
// if this is a leaf node, we don't need to push to children
if (l == r) return;
makeLeft();
makeRight();
left->value = (left->r - left->l + 1);
right->value = (right->r - right->l + 1);
left->lazy = 1;
right->lazy = 1;
}
void makeLeft() {
if (left == nullptr) left = new node(l, (l+r)/2);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |