Poj 2002 && 3432
来源:互联网 发布:在爱奇艺网络剧工作 编辑:程序博客网 时间:2024/05/16 19:30
1Y*2
相同题目
排序点
二分查找
n^2枚举对角线
#include<vector>#include<algorithm>#include<stdio.h>struct point{int x,y;bool operator <(const point &tp)const{if(x!=tp.x)return x<tp.x;return y<tp.y;}bool operator ==(const point &tp)const{return tp.x==x&&tp.y==y;}}tp;std::vector<point>L;int bfind(point t){int l=0,r=L.size()-1;while(r>l){if(r-l==1){if(t==L[r]||t==L[l])return 1;return 0;}int mid=(l+r)/2;if(L[mid]==t)return 1;else if(L[mid]<t)l=mid;else r=mid;}}int main(){int n;while(scanf("%d",&n)!=EOF&&n){int i,j;L.clear();for(i=0;i<n;i++){scanf("%d%d",&tp.x,&tp.y);tp.x*=2;tp.y*=2;L.push_back(tp);}std::sort(L.begin(),L.end());int res=0;for(i=0;i<L.size();i++)for(j=i+1;j<L.size();j++){int x1=L[i].x,x2=L[j].x,y1=L[i].y,y2=L[j].y;tp.x=(x1+x2+y1-y2)/2;tp.y=(y1+y2+x2-x1)/2;if(bfind(tp)){tp.x=(x1+x2-y1+y2)/2;tp.y=(y1+y2-x2+x1)/2;if(bfind(tp)){//printf("%d %d\n",tp.x,tp.y);res++;}}}res/=2;printf("%d\n",res);}return 0;}
- Poj 2002 && 3432
- poj-3432
- POJ 2002
- POJ 2002
- POJ 2002
- poj-2002
- poj 2002
- poj 2002
- poj-2002
- poj 2002
- Poj 2002
- poj 3432 --直接看上一篇2002吧。
- poj 2002 Squares【HASH】POJ最快
- POJ 2002 hash 题目
- poj 2002 Squares
- poj 2002 Squares
- POJ 2002 Squares
- poj 2002 Squares
- 三层和MVC 初识篇
- java IO简介
- linux shell if 条件表达式总结
- JavaScript函数
- js变量以及其作用域详解
- Poj 2002 && 3432
- UVa 10422 - Knights in FEN
- delphi 2007 run按钮灰化无法使用
- java-----集合比较器
- Java学习
- 第k组孪生素数 tzc
- Ubuntu12.04LTS 无线网卡驱动安装BCM4312
- Git add
- properties文件