| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 938973 | vjudge1 | 원숭이와 사과 나무 (IZhO12_apple) | C++17 | 506 ms | 238156 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
struct node{
	int sum, l, r, lazy, ll, lr;
	node(): sum(0), lazy(0), l(-1), r(-1){}
};
node tr[10000000];
int temp=1;
void create(int now){
		int mid=(tr[now].ll+tr[now].lr)>>1;
		if (tr[now].l==-1){
			tr[now].l=temp;
			tr[temp].ll=tr[now].ll;
			tr[temp].lr=mid;
			temp++;
		}
		if (tr[now].r==-1){
			tr[now].r=temp;
			tr[temp].ll=mid+1;
			tr[temp].lr=tr[now].lr;
			temp++;
		}
}
void push(int now){
	create(now);
	if (tr[now].lazy){
		tr[now].sum=tr[now].lr-tr[now].ll+1;
		tr[tr[now].l].lazy=1;
		tr[tr[now].r].lazy=1;
		tr[now].lazy=0;
	}
}
void update(int now, int ql, int qr){
	int l=tr[now].ll, r=tr[now].lr;
	push(now);
	if (ql<=l and r<=qr){
		tr[now].lazy=1;
		push(now);
	} else{
		int mid=(tr[now].ll+tr[now].lr)>>1;
		int cl=tr[now].l, cr=tr[now].r;
		if (ql<=mid) update(cl, ql, qr);
		if (qr>mid) update(cr, ql, qr);
		push(cl);
		push(cr);
		tr[now].sum=tr[cl].sum+tr[cr].sum;
	}
}
int get(int now, int ql, int qr){
	int l=tr[now].ll, r=tr[now].lr;
	push(now);
	if (ql<=l and r<=qr){
		return tr[now].sum;
	} else{
		int mid=(tr[now].ll+tr[now].lr)>>1;
		int cl=tr[now].l, cr=tr[now].r;
		push(cl);
		push(cr);
		int a=0, b=0;
		if (ql<=mid) a=get(cl, ql, qr);
		if (qr>mid) b=get(cr, ql, qr);
		return a+b;
	}
}
int main(){
	int m;
	cin>>m;
	tr[0].sum=0;
	tr[0].ll=1;
	tr[0].lr=1e9;
	int c=0;
	while(m--){
		int d, x, y;
		cin>>d>>x>>y;
		if (d==1){
			c=get(0, x+c, y+c);
			cout<<c<<endl;
		} else{
			update(0, x+c, y+c);
		}
	}
	return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
