# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
13303 | baneling100 | Monkey and Apple-trees (IZhO12_apple) | C++98 | 437 ms | 134136 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 <stdio.h>
#define INF 1073741824
struct node {
node() : left(NULL), right(NULL), cnt(NULL), lazy(NULL) {}
node *left, *right;
int cnt, lazy;
} *Root;
int M, D, X, Y, C;
void countApple(int left, int right, node *now) {
int mid=(left+right)/2;
if(X<=left && right<=Y)
C+=now->cnt;
else {
if(!now->left ) now->left =new node();
if(!now->right) now->right=new node();
if(now->lazy) {
now->left ->cnt =mid-left+1;
now->left ->lazy=1;
now->right->cnt =right-mid;
now->right->lazy=1;
}
if(X<=mid) countApple(left ,mid ,now->left );
if(mid+1<=Y) countApple(mid+1,right,now->right);
if(!now->lazy) {
if(now->left->lazy && now->right->lazy) {
now->cnt =right-left+1;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |