#include<cstring>
#include <cstdio>
#include <iostream>
#include <set>
using namespace std;
struct node {
int x,y;
node(int x=0,int y=0):x(x),y(y){}
bool operator < (const node& rhs)const{
return x < rhs.x || x==rhs.x&&y<rhs.y;
}
};
const int maxn = 15100;
multiset<node> vis;
multiset<node> ::iterator p,p2;
int n;
int main()
{
int T;
scanf("%d",&T);
int kase=1;
while(T--){
vis.clear();
int a,b;
if(kase>1) printf("\n");
printf("Case #%d:\n",kase); kase++;
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d %d",&a,&b);
p=vis.lower_bound(node(a,b));
if(p==vis.begin()||(--p)->y>b){
vis.insert(node(a,b));
p=vis.upper_bound(node(a,b));
/*
本题下面的条件的判定要考虑可行的一面,而从反面考虑方面太多,
*/
while(p!=vis.end()&&p->y>=b) vis.erase(p++); //指针的用法直接可向下++
}
printf("%d\n",vis.size());
}
}
return 0;
}
UVA - 11020(优势人群)
最新推荐文章于 2019-12-18 20:06:00 发布