hsacm-1443
来源:互联网 发布:c语言的指针编程例题 编辑:程序博客网 时间:2024/06/07 14:31
http://hsacm.cn/JudgeOnline/problem.php?id=1443
这题直接用SET就可以做,但是有一个严重的问题就是超时。所以这个时候体现了lower_bound函数的重要性,
lower_bound(B)返回的是不小于B的第一个值得位置。原来SET也可以调用这个函数。
还有一个坑点是HSACM上不能不能用I64d.改成lld分分钟AC.
#include<iostream>#include<cstdio>#include<cmath>#include<vector>#include<cstring>#include<algorithm>#include<string>#include<set>#include<functional> #include<numeric>#include<sstream>#include<stack>#include<map>#include<queue>using namespace std;int main(){ long long n; long long m=1; while(cin >> n && n) { char s[100]; set<pair<long long,long long> > se; set<pair<long long,long long> >::iterator ite; printf("Case %d:\n",m++); while(n--) { scanf("%s",s); pair<long long,long long> p; scanf("%lld%lld",&p.first,&p.second); if(s[0]=='a') se.insert(p); else if(s[0]=='f') { ite = se.lower_bound(p); for(;ite!=se.end();ite++) { if(ite->first>p.first&&ite->second>p.second) { printf("%lld %lld\n",ite->first,ite->second); break; } } if(!(ite!=se.end())) printf("-1\n"); } else if(s[0]=='r') se.erase(p); } printf("\n"); se.clear(); } return 0;}
0 0
- hsacm-1443
- hsacm-1575
- hsacm-1441
- hsacm-1629 拦截导弹
- HSACM 1680 能量项链
- HSACM 1503 公路乘车
- HSACM 1625 Cantor表
- hsacm 字符串训练之AB串
- sicily 1443
- sicily 1443
- hdu-1443
- hdu 1443
- Sicily 1443
- Sicily 1443
- hdu 1443
- HDOJ 1443 Joseph again
- HDU-1443 Joseph
- hdoj 1443 Joseph【水】
- One Importance Difference between Stored Procedure and Stored Function
- 业界良心机构解密:90后更适合学网络营销的六大理由!
- fram和bounds的区别和用途 - iOS - UI基础知识总结2
- shader基础知识
- 五大常用算法之二:动态规划算法
- hsacm-1443
- 【Android】No resource found that matches the given name “xxx” 的解决方法
- 水题
- iOS8 模糊视图(毛玻璃效果) UIVisualEffectView
- 原生态JS取checkbox选中状态
- Mysql基础入门
- ubuntu循环依赖
- 【泽云笔记】让CPU达到100%的方法
- 调侃《Head First设计模式》之迭代器和组合模式(二)