Submission #4851

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
48512014-01-05 08:39:58cki86201Monkey and Apple-trees (IZhO12_apple)C++98
100 / 100
60 ms1208 KiB
#include<stdio.h>
#include<algorithm>
struct segment{
int x;
segment *link[2];
void update(int s,int d,int l,int r)
{
if(x == d-s+1)return;
if(l<=s && d<=r){
x = d-s+1;
return;
}
int m = (s+d)>>1;
if(l<=m){
if(!link[0])link[0] = new segment();
link[0]->update(s,m,l,r);
}
if(r>m){
if(!link[1])link[1] = new segment();
link[1]->update(m+1,d,l,r);
}
x = (link[0]?link[0]->x:0) + (link[1]?link[1]->x:0);
}
int read(int s,int d,int l,int r)
{
if(l<=s && d<=r)return x;
if(x == d-s+1)return std::min(d,r) - std::max(s,l) + 1;
int m = (s+d)>>1, ret = 0;
if(l<=m)ret += link[0]?link[0]->read(s,m,l,r):0;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...