【解题报告】BUPT Online Judge Volume 9 Problem 1805 Segments【计算几何】(水题。因为不会用叉积做,自玩了无数次才AC)

来源:互联网 发布:php 单引号 双引号 编辑:程序博客网 时间:2024/05/13 13:54

Segments

Submit: 386   Accepted:62

Time Limit: 1000MS  Memory Limit: 65536K

Description
There are some segments on the plane, we assume there 4 possible position concepts for every 2 segments: no common point, countless common points, one common point and the point is also the endpoint of either segment, one common point but the point is not the endpoint of either segment.
译文:平面上有若干线段。线段两两间存在4种可能的位置关系:无公共点,无数公共点,一个公共点且为其中一条的端点,一个公共点但不是端点。


tupian

 

 

Input
The first line of the input is an integer T, which represents that there are T test cases.
An integer n indicating the number of segments
n line follows, 4 integers per line, x1, y1, x2, y2, representing the coordinates of the endpoints of both segments .(1<=n<=100)
译文:第一行测试数据组数T;第二行每组中线段数n;接下来n行线段两端点的二维坐标。(n不超过100

Output
For each test case, please output 4 line, 1 integer per line
For the first line, please output the number of pairs of segments that have no common point
For the second line, please output the number of pairs of segments that have countless common point
For the third line, please output the number of pairs of segments that have 1 common point and the point is also the endpoint of either segment
For the fourth line, please output the number of pairs of segments that have 1 common point and the point is not the endpoint.
After each case output a blank line include the last case

译文:输出四行,分别是对应四种情况的线段对的数目,每组测试数据后输出一个空行。

Sample Input

2
3
-1 0 1 0
0 -1 0 1
-1 2 1 2
3
1 0 3 0
2 0 4 0
4 0 5 0


Sample Output

2
0
0
1

1
1
1
0


Source
第四届北京邮电大学程序设计竞赛决赛

 

 Code

 

原创粉丝点击