zoukankan      html  css  js  c++  java
  • uva 11020

    用可重集;

    首先按照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:
    ",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
    ",s.size());
    39         }
    40         if(t>0)puts("");
    41     }
    42     return 0;
    43 }
    View Code
  • 相关阅读:
    LOAD XML
    LOAD DATA
    INSERT 插入语句
    keras第一课
    android系统开发之开启启动
    Qt使用数据库
    微信订阅号案例之一
    python_install
    QtObject使用
    Qml_JS文件的使用
  • 原文地址:https://www.cnblogs.com/yours1103/p/3400505.html
Copyright © 2011-2022 走看看