Parallelogram Counting Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 6895   Accepted: 2423 Description There are n distinct points in the plane, given by their integer coordinates. Find the number of parallelograms whose vertices…
题目链接: http://poj.org/problem?id=1971 题意: 二维空间给n个任意三点不共线的坐标,问这些点能够组成多少个不同的平行四边形. 题解: 使用的平行四边形的判断条件:对角线互相平分的四边形是平行四边形. 所以我们枚举每一条线段,如果有两条线段的中点是重合的,那么这四个顶点就能构成一个平行四边形,也就是说每条线段我们只要维护中点就可以了. 1.map维护中点:(数据比较大,t了) #include<iostream> #include<cstdio> #…
Parallelogram Counting 刚学hash还不会用,看到5000ms的时限于是想着暴力来一发应该可以过.以前做过类似的题,求平行四边形个数,好像是在CF上做的,但忘了时限是多少了,方法是一样的. 题意:给出n个点坐标,求平面中有多少个平行四边形. 思路:我们知道,平行四边形的条件是两条边平行且相等.我们把每条边分解成x和y方向的向量,只要两条边对应相等就可以了,于是预处理所有的边,然后排序,然后相等的肯定在一起,所以用试探法往前,注意每个平形四边形都被记录了两次,所以答案是总数量…
Description There are n distinct points in the plane, given by their integer coordinates. Find the number of parallelograms whose vertices lie on these points. In other words, find the number of 4-element subsets of these points that can be written a…
Parallelogram Counting Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 5749   Accepted: 1934 Description There are n distinct points in the plane, given by their integer coordinates. Find the number of parallelograms whose vertices lie o…
1058 - Parallelogram Counting    PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB There are n distinct points in the plane, given by their integer coordinates. Find the number of parallelograms whose vertices lie on these po…
1058 - Parallelogram Counting There are n distinct points in the plane, given by their integer coordinates. Find the number of parallelograms whose vertices lie on these points. In other words, find the number of 4-element subsets of these points tha…
题目链接:http://poj.org/problem?id=1971 题意:给定n个坐标.问有多少种方法可以组成平行四边形.题目保证不会有4个点共线的情况. 思路:可以发现平行四边形的一个特点,就是对角线相交后得到的点.如果两点线的中点相交,那么这两条线就可以组成一个平行四边形[不需去排除4点共线],所以枚举两两组合的点对HASH成中点.然后判断所有中点,如果某个中点出现了K次,那么可以组成K*(K-1)/2个平行四边形. 用map来判断某个中点出现次数会TLE,所以可以对中点进行排序后判重复…
题目链接:http://poj.org/problem?id=2021 思路分析:由于数据较小,采用O(N^2)的暴力算法,算出所有后代的年龄,再排序输出. 代码分析: #include <iostream> #include <string.h> #include <algorithm> using namespace std; #define MAX_N ( 100 + 10 ) typedef struct Descendant { ]; int Age; }De…
题目:  http://poj.org/problem?id=3714 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=27048#problem/D Raid Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 7355   Accepted: 2185 Description After successive failures in the battles aga…