# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1141327 | yytsi | Monkey and Apple-trees (IZhO12_apple) | C++17 | 381 ms | 327524 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->lazy = 1;
right->lazy = 1;
}
void makeLeft() {
if (left == nullptr) left = new node(l, (l+r)/2);
}
void makeRight() {
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |