#include<bits/stdc++.h>
using namespace std;
int n,m;
int a[400010];
int sum[400010];
int s[4000010];
int maxsum;
int Pow;
int ans1,ans2;
void Build(int id,int l,int r)
{
if(l == r)
{
maxsum = max(maxsum,id);
sum[id] = 1;
s[id] = 1;
return;
}
int mid = l + r >> 1;
Build(id * 2,l,mid);
Build(id * 2 + 1,mid + 1,r);
sum[id] = sum[id * 2] + sum[id * 2 + 1];
s[id] = s[id * 2] + s[id * 2 + 1];
maxsum = max(maxsum,id);
}
void unplant(int id,int l,int r,int x,int y){
if(l < x && r < x || l > y && r > y)
{
return;
}
if(l == r)
{
if(s[id] == 2)
{
ans2 ++;
}
sum[id] = 0;
s[id] = 0;
return;
}
int mid = l + r >> 1;
unplant(id * 2,l,mid,x,y);
unplant(id * 2 + 1,mid + 1,r,x,y);
sum[id] = sum[id * 2] + sum[id * 2 + 1];
}
void plant(int id,int l,int r,int x,int y)
{
if(l < x && r < x || l > y && r > y)
{
return;
}
if(l == r)
{
if(sum[id] == 0) s[id] = 2,ans1 ++;
sum[id] = 1;
return;
}
int mid = l + r >> 1;
plant(id * 2,l,mid,x,y);
plant(id * 2 + 1,mid + 1,r,x,y);
sum[id] = sum[id * 2] + sum[id * 2 + 1];
}
int main()
{
scanf("%d%d",&n,&m);
Build(1,1,n);
for(int i = 1;i <= m;i ++)
{
int x,y,z;
scanf("%d%d%d",&x,&y,&z);
if(x == 0)
{
unplant(1,1,n,y,z);
}
else
{
plant(1,1,n,y,z);
}
}
printf("%d\n%d",ans1 - ans2,ans2);
return 0;
}
共 1 条回复