PKU 3432 Count Squares
来源:互联网 发布:getrow java 编辑:程序博客网 时间:2024/05/19 08:03
Count SquaresTime Limit: 3000MS
Memory Limit: 65536KTotal Submissions: 1331
Accepted: 552
题目意思很简单,给一群不同的点,求这些点最多组成了几个正方形。
每此枚举2个点,作为正方行的一条边,然后顺时针/逆时针旋转90度(利用相对坐标来计算),得到另外2个点的坐标,查询HASH看这2个点如果都存在那么cnt++;
最后cnt/4,因为一个正方形被算过4次
Memory Limit: 65536KTotal Submissions: 1331
Accepted: 552
Description
Given a set of points with integer coordinates xi, yi, i = 1...N, your program must find all the squares having each of four vertices in one of these points.
Input
Input file contains integer N followed by N pairs of integers xi yi.
Constraints
-104 ≤ xi, yi ≤ 104, 1 ≤ N ≤ 2000. All points in the input are different.
Output
Output file must contain a single integer — number of squares found.
Sample Input
Sample input 1
4 0 0 4 3 -3 4 1 7
Sample input 2
9
1 1 1 2 1 3
2 1 2 2 2 3
3 1 3 2 3 3
Sample Output
Sample output 1
1
Sample output 2
6
Hint
Bold texts appearing in the sample sections are informative and do not form part of the actual data.Source
Northeastern Europe 2005, Far-Eastern Subregion题目意思很简单,给一群不同的点,求这些点最多组成了几个正方形。
每此枚举2个点,作为正方行的一条边,然后顺时针/逆时针旋转90度(利用相对坐标来计算),得到另外2个点的坐标,查询HASH看这2个点如果都存在那么cnt++;
最后cnt/4,因为一个正方形被算过4次
- for(i=0;i<n;i++)
- for(j=0;j<n;j++)
- {
- if(i==j)continue;
- //下面是重点-坐标变换
- TMP.x=P[j].y-P[i].y+P[j].x;
- TMP.y=P[i].x-P[j].x+P[j].y;
- if(isin(TMP))//isin查询HASH表中点是否存在
- {
- //坐标变换,得到另一个点
- TMP.x+=(P[i].x-P[j].x);
- TMP.y+=(P[i].y-P[j].y);
- if(isin(TMP))
- cnt++;
- }
- }
- printf("%d/n",cnt/4);
- PKU 3432 Count Squares
- Count Squares HDU 3432
- poj3432---Count Squares
- pku 2002 -- Squares(二分,几何)
- PKU 2777 Count Color
- PKU 2777 Count Color
- PKU 2777 Count Color
- POJ3432《Count Squares》方法:哈希
- pku 1016 Numbers That Count
- PKU 1016 Numbers That Count
- pku 2777 Count Color(线段树变形)
- [PKU] 2777 Count Color -- 线段树
- PKU ACM 1016 Numbers That Count
- Squares
- Squares
- Squares
- Squares
- Squares
- 怎样在google上搜索编程资源
- Eclipse快捷键大全
- 彩信(MMS)开发经验点滴(mm7 api)
- (已加马赛克)10 行代码判定色*情*图片——Python 也可以系列之二
- alv_interface
- PKU 3432 Count Squares
- Java调用SQL Server存储过程同时返回参数和结果集
- 永远的食粮
- error C2061: syntax error : identifier 'THIS_FILE'
- 获取表结构
- 一日精通Ajax技术
- 英国封杀 Wikipedia 后续:Wikipedia 的英国编辑遭封杀
- Linux经典命令介绍 ---- mkdir
- abs ()函数