Uva 11120 Efficient Solutions
来源:互联网 发布:模拟期权交易软件 编辑:程序博客网 时间:2024/05/17 06:19
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1961
本题题意是求每一次查询的优势的人数,我们可以用现成的multiset代替原本的平衡树。
mulitse可以存储相同的两个元素。排序方式可以自定义。
#include <iostream>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <algorithm>#include <set>using namespace std;struct Point{ int x,y; Point(int _x,int _y) { x = _x; y = _y; } bool operator < (const Point & rhs) const { return x < rhs.x || (x == rhs.x && y < rhs.y); }};multiset<Point> S;multiset<Point>::iterator it;int main(){#ifndef ONLINE_JUDGE freopen("in.txt","r",stdin);#endif int t; int n; int x,y; int cas = 0; scanf(" %d",&t); while(t--) { cas++; printf("Case #%d:\n",cas); S.clear(); scanf(" %d",&n); for(int i=0;i<n;i++) { scanf(" %d %d",&x,&y); Point a(x,y); it = S.lower_bound(a); if(it == S.begin() || (--it)->y > y ) { S.insert(a); it = S.upper_bound(a); while(it!=S.end() && it->y >= y) { S.erase(it++); } } printf("%d\n",S.size()); } if(t!=0) puts(""); } return 0;}
- Uva 11120 Efficient Solutions
- Uva-11020-Efficient Solutions
- UVA 11020 Efficient Solutions
- UVA 11020 - Efficient Solutions
- UVA 11020 - Efficient Solutions(set)
- uva 11020 - Efficient Solutions(STL)
- UVA 11020 Efficient Solutions set
- UVA 11020 Efficient Solutions(multiset,数据结构)
- UVA 11020 Efficient Solutions(C++STL应用)
- UVA 11020(Efficient Solutions-multiset的lower_bound)
- UVA 11020 Efficient Solutions+multiset的应用
- UVA 11020 Efficient Solutions(BST multiset实现)
- UVA 11020 Efficient Solutions(STL,set)
- Uva 11020 Efficient Solutions (set的应用)
- UVA - 11020 - Efficient Solutions (multiset实现BST)
- UVA 11020 Efficient Solutions (用multiset实现BST)
- UVA11020 Efficient Solutions
- uva11020 Efficient Solutions mutiset
- ios操作通讯录的例子
- 题目1482:玛雅人的密码
- Webstorm 6.0的序列号和证书
- java如何调用libsvm
- 分享代码---将iamge保存成png或jpeg格式
- Uva 11120 Efficient Solutions
- 设计模式之策略模式
- Eclipse 黑色风格
- 第5章:表达式
- .Net事件
- 在wdcp下正常使用vpn
- PC 的 110704 和 UVa 上的 10139 提交结果
- 如何让内网访问外网的共享?
- 几种ESB(企业服务总线)介绍