uva 11020 - Efficient Solutions ——平衡BST


链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1961

训练指南page228

 1 #include <cstdio>
 2 #include <set>
 3 using namespace std;
 4 struct Point
 5 {
 6     int a, b;
 7     bool operator < (const Point & other) const
 8     {
 9         return (a < other.a) || (a == other.a && b < other.b);
10     }
11 };
12 multiset<Point> S;
13 multiset<Point>::iterator it;
14 int main(void)
15 {
16     #ifndef ONLINE_JUDGE
17      freopen("11020.in", "r", stdin);
18     #endif // ONLINE_JUDGE
19     int T; scanf("%d", &T);
20     for (int i = 1; i <= T; ++i)
21     {
22         printf("Case #%d:\n", i); int n, a, b; scanf("%d", &n); S.clear();
23         while (n--)
24         {
25             scanf("%d%d", &a, &b); Point P = (Point){a, b}; it = S.lower_bound(P);
26             if (it == S.begin() || (--it)->b > b) S.insert(P), it = S.upper_bound(P);
27             while (it != S.end() && it->b >= b) S.erase(it++);
28             printf("%d\n", S.size());
29         }
30         if (i!=T) printf("\n");
31     }
32     return 0;
33 }

。。

  本来想睡觉的,这题看了一半,还是做完吧,贴完睡觉。

  今天身体超级难受……好久没生过病了,没想到这么痛苦,o(╯□╰)o头疼,浑身上下都不舒服,下午去机房,那个难受啊,我去……赶紧回来了,晚上在综合楼还好一点,以后就住在综合楼和KFC和书院九号了。头晕,睡觉……

  对了,明天晚上跑步去,不去锻炼一下一点儿也没意思……什么毛病都出来了。。=_=

  晚安。

优质内容筛选与推荐>>
1、js获取当前页面信息
2、使用jconsole检测linux服务器
3、<一>初探js特效魅力之全选不选反选04
4、css样式大全(整理版)
5、关于 Content-Encoding: gzip - 知道创宇


长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号