POJ 1971 Parallelogram Counting (Hash)
| Time Limit: 5000MS | Memory Limit: 65536K | |
| Total Submissions: 6895 | Accepted: 2423 |
Description
Input
The first line of each test case contains an integer n (1 <= n <= 1000). Each of the next n lines, contains 2 space-separated integers x and y (the coordinates of a point) with magnitude (absolute value) of no more than 1000000000.
Output
Line i contains an integer showing the number of the parallelograms as described above for test case i.
Sample Input
2
6
0 0
2 0
4 0
1 1
3 1
5 1
7
-2 -1
8 9
5 7
1 1
4 8
2 0
9 8
Sample Output
5
6 思路:
没有思路。
暴力:TLE
hash:TLE
直接怀疑人生。
在此之间,我甚至怀疑了POJ是不是卡了我的map,后来改成模拟链表。。。。TLE!!
我。。。。。
TLE代码之一:
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
typedef unsigned long long ll;
const int maxn = 1024;
ll x[maxn],y[maxn];
ll state[1000086];
int head[maxn];
int num[maxn],Next[1000086];
int main()
{
int n,T;
ll sd;
scanf("%d",&T);
while(T--){
int ans=0;
scanf("%d",&n);
memset(head,-1,sizeof(head));
int t=0;
for(int i=1;i<=n;i++){
scanf("%lld%lld",&x[i],&y[i]);
for(int j=1;j<i;j++){
sd=(x[i]+x[j])*10000009+y[i]+y[j];
int h=sd%maxn;
for(int k=head[h];k!=-1;k=Next[k]){
if(state[k]==sd){ans++;}
}
t++;
state[t]=sd;
Next[t]=head[h];
head[h]=t;
}
}
printf("%d\n",ans);
}
}
POJ 1971 Parallelogram Counting (Hash)的更多相关文章
- POJ 1971 Parallelogram Counting
题目链接: http://poj.org/problem?id=1971 题意: 二维空间给n个任意三点不共线的坐标,问这些点能够组成多少个不同的平行四边形. 题解: 使用的平行四边形的判断条件:对角 ...
- POJ 1971 统计平行四边形 HASH
题目链接:http://poj.org/problem?id=1971 题意:给定n个坐标.问有多少种方法可以组成平行四边形.题目保证不会有4个点共线的情况. 思路:可以发现平行四边形的一个特点,就是 ...
- POJ 1791 Parallelogram Counting(求平行四边形数量)
Description There are n distinct points in the plane, given by their integer coordinates. Find the n ...
- 计算几何 + 统计 --- Parallelogram Counting
Parallelogram Counting Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 5749 Accepted: ...
- Parallelogram Counting(平行四边形个数,思维转化)
1058 - Parallelogram Counting PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit ...
- 1058 - Parallelogram Counting 计算几何
1058 - Parallelogram Counting There are n distinct points in the plane, given by their integer coord ...
- POJ 2002 统计正方形 HASH
题目链接:http://poj.org/problem?id=2002 题意:给定n个点,问有多少种方法可以组成正方形. 思路:我们可以根据两个点求出对应正方形[有2个一个在两点左边,一个在两点右边] ...
- POJ 3320 (尺取法+Hash)
题目链接: http://poj.org/problem?id=3320 题目大意:一本书有P页,每页有个知识点,知识点可以重复.问至少连续读几页,使得覆盖全部知识点. 解题思路: 知识点是有重复的, ...
- poj 1840 Eqs (hash)
题目:http://poj.org/problem?id=1840 题解:http://blog.csdn.net/lyy289065406/article/details/6647387 小优姐讲的 ...
随机推荐
- SSH本地端口转发的理解
ssh -L 3307:127.0.0.1:3306 user@ssh-server -N 其中127.0.0.1:3306是指 ssh-server要访问资源的ip和端口 而3307则是隧道的开口, ...
- python 计算机基础
1.什么是编程语言. 语言是一个事物与另一个事物沟通的介质. 编程语言是程序员与计算机沟通的介质. 2.什么是编程. 编程是人按照某种语法规范设计出计算机能够识别的语言 表达的结果是程序,程序就是一系 ...
- Web API2 使用EF Code Migrations to Seed DB
console Enable-Migrations 运行这个命令,添加一个文件夹Migrations,Configuration.cs在这文件夹中 打开 Configuration.cs file. ...
- Mysql 计划任务
-- 设置 show variables like '%sche%'; ; -- Start存储过程 drop PROCEDURE if exists test; CREATE PROCEDURE t ...
- yoj维护
维护 启动容器 docker start yoj 暂停容器 docker stop yoj 重启容器 docker restart yoj 进入容器的终端 docker attach yok 保存容器 ...
- opencv 图片缩放
import cv2 as cv import numpy as np # 图片缩放 img = cv.imread('../images/moon.jpg', flags=1) # flags=1读 ...
- MT【296】必要性探路
已知$a,b\in R.f(x)=e^x-ax+b$,若$f(x)\ge1$恒成立,则$\dfrac{b-a}{a}$的取值范围_____ 提示:答案:$[-1,\infty)$取$x=0,b\ge0 ...
- 【BZOJ5300】[CQOI2018]九连环 (高精度,FFT)
[BZOJ5300][CQOI2018]九连环 (高精度,FFT) 题面 BZOJ 洛谷 题解 去这里看吧,多么好 #include<iostream> #include<cstdi ...
- linux中,使用cat、head、tail命令显示文件指定行
小文件可以用cat(也可以用head.tail) 显示文件最后20行:cat err.log | tail -n 20 显示文件前面20行:cat err.log | head -n 20 从20行开 ...
- bzoj3959(LCT)
题目描述 某校开展了同学们喜闻乐见的阳光长跑活动.为了能“为祖国健康工作五十年”,同学们纷纷离开寝室,离开教室,离开实验室,到操场参加3000米长跑运动.一时间操场上熙熙攘攘,摩肩接踵,盛况空前. 为 ...