蒟蒻太蒻了,所以想找道题练练set,但是打挂了,有没有大佬知道错哪里了,全部RE
#include<bits/stdc++.h>
using namespace std;
inline void read(int &x){
x=0;int f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-') f=-f;ch=getchar();}
while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
x*=f;return;
}
inline void put(int x){
if(x<0) putchar('-'),x=-x;
if(x>9) put(x/10);
putchar(x%10+'0');return;
}inline void write(int x){put(x);putchar('\n');}
struct Range{int l,r;};
struct cmp1{
inline bool operator () (const Range a,const Range b) const{
if(a.l==b.l)return a.r<b.r;
return a.l<b.l;
}
};
struct cmp2{
inline bool operator () (const Range a,const Range b) const{
if(a.r==b.r)return a.l<b.l;
return a.r<b.r;
}
};
set<Range,cmp2> a;
set<Range,cmp1> b;
int n;char opt;Range ran;
set<Range>::iterator pos,beg;
Range now;
signed main(){
read(n);
while(n--){
scanf("%c",&opt);
if(opt=='B'){write(a.size());continue;}
read(ran.l),read(ran.r);
if(a.empty()){
a.insert(ran);
b.insert(ran);
write(0);continue;
}
int lstSiz=a.size();
pos=a.lower_bound(ran);
pos--;beg=--a.begin();
for(auto i=pos;i!=beg;i--){
now=*i;
if(now.r<ran.l) break;
if(a.count(now)&&!a.empty()) a.erase(now);
if(b.count(now)&&!b.empty()) b.erase(now);
}
pos=b.lower_bound(ran);
beg=b.end();
for(auto i=pos;i!=beg;i++){
now=*i;
if(now.l>ran.r) break;
if(a.count(now)&&!a.empty()) a.erase(now);
if(b.count(now)&&!b.empty()) b.erase(now);
}
int nowSiz=a.size();
write(lstSiz-nowSiz);
a.insert(ran);b.insert(ran);
}
return 0;
}