uva 11020 - Efficient Solutions
生活随笔
收集整理的這篇文章主要介紹了
uva 11020 - Efficient Solutions
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
用可重集;
首先按照x排好序,然后只要找到下界,插入,然后把y坐標大于它的都刪掉就行;
1 #include<cstdio> 2 #include<set> 3 using namespace std; 4 5 struct node 6 { 7 int a,b; 8 bool operator<(const node &t)const 9 { 10 if(a==t.a)return b<t.b; 11 return a<t.a; 12 } 13 }; 14 15 multiset<node>s; 16 multiset<node>::iterator it; 17 18 int main() 19 { 20 int t,n,ca=1; 21 node p; 22 scanf("%d",&t); 23 while(t--) 24 { 25 s.clear(); 26 printf("Case #%d:\n",ca++); 27 scanf("%d",&n); 28 while(n--) 29 { 30 scanf("%d%d",&p.a,&p.b); 31 it=s.lower_bound(p); 32 if(it==s.begin()||(--it)->b >p.b) 33 { 34 s.insert(p); 35 it=s.upper_bound(p); 36 while(it!=s.end()&&it->b>=p.b)s.erase(it++); 37 } 38 printf("%d\n",s.size()); 39 } 40 if(t>0)puts(""); 41 } 42 return 0; 43 } View Code?
轉載于:https://www.cnblogs.com/yours1103/p/3400505.html
總結
以上是生活随笔為你收集整理的uva 11020 - Efficient Solutions的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: StarlingMVC Framewor
- 下一篇: 生活的态度