POJ 1971 Parallelogram Counting (Hash)】的更多相关文章

      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> #…
题目链接:http://poj.org/problem?id=1971 题意:给定n个坐标.问有多少种方法可以组成平行四边形.题目保证不会有4个点共线的情况. 思路:可以发现平行四边形的一个特点,就是对角线相交后得到的点.如果两点线的中点相交,那么这两条线就可以组成一个平行四边形[不需去排除4点共线],所以枚举两两组合的点对HASH成中点.然后判断所有中点,如果某个中点出现了K次,那么可以组成K*(K-1)/2个平行四边形. 用map来判断某个中点出现次数会TLE,所以可以对中点进行排序后判重复…
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=2002 题意:给定n个点,问有多少种方法可以组成正方形. 思路:我们可以根据两个点求出对应正方形[有2个一个在两点左边,一个在两点右边]另外两个点的左边.例如 已知:(x1,y1) (x2,y2)则x3=x1+(y1-y2) y3= y1-(x1-x2) x4=x2+(y1-y2) y4= y2-(x1-x2)或x3=x1-(y1-y2) y3= y1+(x1-x2) x4=x2-(y1-y2) y4= y2+(x1-x2) 枚举两…
题目链接: http://poj.org/problem?id=3320 题目大意:一本书有P页,每页有个知识点,知识点可以重复.问至少连续读几页,使得覆盖全部知识点. 解题思路: 知识点是有重复的,因此需要统计不重复元素个数,而且需要记录重复个数. 最好能及时O(1)反馈不重复的个数.那么毫无疑问,得使用Hash. 推荐使用map,既能Hash,也能记录对于每个key的个数. 尺取的思路: ①不停扩展R,并把扫过知识点丢到map里,直到map的size符合要求. ②更新结果. ②L++,map…
题目:http://poj.org/problem?id=1840 题解:http://blog.csdn.net/lyy289065406/article/details/6647387 小优姐讲的很好了 #include<cstdio> #include<string> #include<iostream> #include<cstring> #include<map> using namespace std; ]; int main() {…