# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
379036 | daniel920712 | Segments (IZhO18_segments) | C++14 | 0 ms | 0 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 <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
pair < int , int > all[200005];
bool have[200005];
struct A
{
int here;
int nxl,nxr;
bool have;
int sz;
int con;
int rnd;
}Node[500005];
int root1=0;
int root2=2e5+50;
int st1=0;
int st2=2e5+50;
int Merge(int a,int b)
{
if(a==st1||a==st2) return b;
if(b==st1||b==st2) return a;
if(Node[a].rnd>Node[b].rnd)
{
Node[a].nxr=Merge(Node[a].nxr,b);
UPD(a);
return a;
}
else
{
Node[b].nxl=Merge(a,Node[b].nxl);
UPD(b);
return b;
}
}
/*pair < int , int > split(int here,int con)
{
if(here==st1||here==st2) return make_pair(here,here);
}*/
int main()
{
int N,M,ans=0,now=0,a,b,l,r,t,i;
scanf("%d %d",&N,&M);
while(N--)
{
scanf("%d",&a);
if(a==1)
{
scanf("%d %d",&l,&r);
l=l^(M*ans);
r=r^(M*ans);
now++;
have[now]=1;
all[now]=make_pair(l,r);
Node[st1+now].here=l;
Node[st1+now].have=1;
Node[st2+now].here=r;
Node[st2+now].have=1;
}
else if(a==2)
{
scanf("%d",&l);
have[l]=0;
}
else
{
scanf("%d %d %d",&l,&r,&t);
l=l^(M*ans);
r=r^(M*ans);
ans=0;
if(l>r) swap(l,r);
for(i=1;i<=now;i++)
{
if(have[i]==0) continue;
a=max(l,all[i].first);
b=min(r,all[i].second);
if(b-a+1>=t) ans++;
}
printf("%d\n",ans);
}
}
return 0;
}
/*
6 0
1 3 10
1 3 5
3 6 10 6
2 1
1 3 10
3 6 4 2
*/