Submission #343593

# Submission time Handle Problem Language Result Execution time Memory
343593 2021-01-04T08:57:00 Z ogibogi2004 Monkey and Apple-trees (IZhO12_apple) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
const int INF=1e9;
int cnt_nodes=0;
struct tree
{
	struct node
	{
		node *l,*r;
		bool minval;
		int cnt;
		bool lazy;
		node(int _cnt)
		{
			l=nullptr;
			r=nullptr;
			minval=0;cnt=_cnt;
		}
	};
	node* root=nullptr;
	node* xd;
	node* merge(node *n1,node *n2,int L,int R)
	{
		if(!n1)return n2;
		if(!n2)return n1;
		node *ret=new node(R-L+1);
		if(n1->minval==n2->minval)
		{
			tie(ret->minval,ret->cnt)=make_pair(n1->minval,n1->cnt+n2->cnt);
		}
		else tie(ret->minval,ret->cnt)=min(make_pair(n1->minval,n1->cnt),make_pair(n2->minval,n2->cnt));
		ret->l=n1;ret->r=n2;
		return ret;
	}
	void push(node *&t,int L,int R)
	{
		if(!t)t=new node(R-L+1);
		if(t->lazy>=1)
		{
			if(L!=R)
			{
				int mid=(L+R)/2;
				if(t->l)
				{
					t->l->lazy|=1;
				}
				else 
				{
					t->l=new node(mid-L+1);
					t->l->lazy|=1;
				}
				if(t->r)
				{
					t->r->lazy|=1;
				}
				else 
				{
					t->r=new node(R-mid);
					t->r->lazy|=1;
				}
			}
			t->minval=1;
			t->lazy=0;
		}
		//return t;
	}
	void upd(node *&t,int L,int R,int ql,int qr)
	{
		push(t,L,R);
		if(L>qr||R<ql)return;
		if(L>=ql&&R<=qr)
		{
			t->lazy=1;
			push(t,L,R);
			return;
		}
		int mid=(L+R)/2;
		if(mid+1>qr)upd(t->l,L,mid,ql,qr);
		if(mid<ql)upd(t->r,mid+1,R,ql,qr);
		t=merge(t->l,t->r,L,R);
	}
	node* query(node *t,int L,int R,int ql,int qr)
	{	
		push(t,L,R);
		if(L>qr||R<ql)return NULL;
		if(L>=ql&&R<=qr)
		{
			return t;
		}
		int mid=(L+R)/2;
		if(mid<ql)reurn query(t->r,mid+1,R,ql,qr);
		else if(mid+1>qr)return query(t->l,L,mid,ql,qr);
		return merge(query(t->l,L,mid,ql,qr),query(t->r,mid+1,R,ql,qr),L,R);
	}
	void print(node* t)
	{
		if(!t)return;
		cnt_nodes++;
		cout<<t->cnt<<" "<<t->minval<<" "<<t->cnt<<endl;
		print(t->l);
		print(t->r);
	}
}st;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int c=0;
	int m,d,x,y;
	cin>>m;
	/*if(m>60000)
	{
		cout<<0<<endl;
		return 0;
	}*/
	while(m--)
	{
		cin>>d>>x>>y;
		x+=c;y+=c;
		if(d==1)
		{
			st.xd=st.query(st.root,1,INF,x,y);
			if(st.xd->minval>0)
			{
				c=y-x+1;
			}
			else c=y-x+1-st.xd->cnt;
			cout<<c<<endl;
		}
		else st.upd(st.root,1,INF,x,y);
		/*st.print(st.root);
		cout<<"fdsf "<<cnt_nodes<<endl;
		cnt_nodes=0;*/
	}
	/*for(int i=0;i<10;i++)
	{
		for(int j=i+1;j<10000;j++)
		{
			st.root=st.upd(st.root,0,INF,i,j);
		}
	}
	st.print(st.root);
	cout<<cnt_nodes<<endl;*/
return 0;
}

Compilation message

apple.cpp: In member function 'tree::node* tree::query(tree::node*, int, int, int, int)':
apple.cpp:91:13: error: 'reurn' was not declared in this scope
   91 |   if(mid<ql)reurn query(t->r,mid+1,R,ql,qr);
      |             ^~~~~