STL初入
来源:互联网 发布:人证比对软件 编辑:程序博客网 时间:2024/06/07 01:47
昨日思路有缺陷再加一个vector排序即可代码如下:
#include#include#include#includeusing namespace std;typedef struct Point{ int x,y; Point (int x= 0,int y = 0):x(x),y(y){}};vector dot,dot1;bool flag;Point operator (const Point& A, const Point& B){ return Point(A.x B.x,A.y B.y);}bool compare(const Point& A, const Point& B){ if(A.x != B.x) return A.x else return A.y}bool compare1(const Point& A, const Point& B){ if(A.x != B.x) return A.x else return A.y>B.y;}int main(){ //freopen("in.txt","r",stdin); int T; cin>>T; while(T--) { dot.clear(); dot1.clear(); int n; Point spot; cin>>n; for(int i = 0; i < n; i ) { cin>>spot.x>>spot.y; dot.push_back(spot); dot1.push_back(spot); } sort(dot.begin(),dot.end(),compare); sort(dot1.begin(),dot1.end(),compare1); flag = true; int tmp = dot[0].x dot1[n-1].x; for(int i = 0; i < n/2; i ) { if(dot[i].x dot1[n-1-i].x != tmp || dot[i].y != dot1[n-i-1].y) { flag = false; break; } } if(flag) cout<<"YES"<
0 0
- STL初入
- STL学习总结之初入容器
- STL 浅入 容器 (一)
- 初入
- 初入
- 初入
- 初入
- 初入
- 初入SOA
- 初入茅庐
- 初入大学
- 初入社会
- 初入linux
- 初入Ddraw
- 初入江湖
- 初入Emacs
- 初入linux大门
- 初入软件架构
- JDBC
- JDBC
- 确定比赛名次(拓扑排序)
- 剑指offer-34.第一个只出现一次的字符
- [BZOJ2338][HNOI2011]数矩形(计算几何)
- STL初入
- Android Bitmap之擦掉图片(扒衣服)
- SQL Server如何启用xp_cmdshell组件
- cmake的使用
- 护照阅读机出入境运用SDK
- mysql入门知识
- 用会声会影剪辑视频快速入门技巧
- [李景山php]centos7 安装php 多线程
- POJ 2718 Smallest Difference(贪心 or next_permutation暴力枚举)