1 #include 2 #include 3 #include 4 typedef __int64 LL; 5 #define MAXN 30010 6 using namespace std; 7 struct Plant 8 { 9 int x1,y1,x2,y2,s; 10 }; 11 struct Seg 12 { 13 int left,right,high,flag; 14 friend bool operator<(Seg a,Seg b) 15 { 16 if(a.high==b.high) 17 return a.flag >1; 50 if(x<=mid) 51 Update(x,y,flag,L,mid,rt<<1); 52 if(y>mid) 53 Update(x,y,flag,mid+1,R,rt<<1|1); 54 PushUp(L,R,rt); 55 } 56 } 57 int main() 58 { 59 LL temp,ans; 60 int t,n,m,i,j,cnt,nx,x,y,ca=1; 61 scanf("%d",&t); 62 while(t--) 63 { 64 scanf("%d%d",&n,&m); 65 m++; 66 price[0]=0; 67 for(i=1;i =price[i]) 86 { 87 s[cnt].left=p[j].x1; 88 s[cnt].right=p[j].x2; 89 s[cnt].high=p[j].y1; 90 s[cnt++].flag=1; 91 s[cnt].left=p[j].x1; 92 s[cnt].right=p[j].x2; 93 s[cnt].high=p[j].y2; 94 s[cnt++].flag=-1; 95 } 96 } 97 sort(s,s+cnt); 98 for(temp=j=0;j