Problem A: Triangles
Time Limit: 2 Sec Memory Limit: 128 MB Submit: 20 Solved: 9 [ ][ ][ ]Description
You are given a figure consisting of n points in a 2D-plane and m segments connecting some of them. We guarantee that any two segments don’t share points except their ends and there’s no more than one segment between the same pair of points. Please count the total number of triangles in the given figure.
Input
There’re multiple test cases. In each case: The first line contains two positive integers n and m. (n ≤ 200, m ≤ 20000)
Each of the following n lines contains two real numbers xi and yi indicating the coordinates of the i-th point. (−100000 < xi, yi < 100000)
Each of the following m lines contains four real numbers xi, yi, xj, yj . It means (xi,yi) and (xj,yj) are connected by a segment. We guarantee that these points are part of the given n points.
Output
For each test case, print a single line contains the total number of triangles in the given figure.
Sample Input
Sample Output
3
這個題目一開始看沒有看懂題目,不明白爲什麽說明了點還要說明邊,就沒有去寫對我來說第二個難點就是不知道如何去實現邊關係的存儲,雖然以前寫過用二維數組實現邊關係的存儲,而這題有一點不同,在usc_w隊長的指導下,明白了要用map實現哈希對應如此來就是一道簡單的搜索題目了
#include#include #include