시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
10 초 (추가 시간 없음) | 1024 MB | 100 | 8 | 6 | 6.383% |
Peter is bored during his operating systems class, so he draws doodles on a sheet of paper. He feels like drawing abstract art using his ruler: he draws line segments by choosing two points in the plane and connecting them. Lots of them.
Can you write a program that counts the number of distinct points at which the line segments he drew intersect or touch?
The first line in the input contains an integer $n$ ($1 \le n \le 1\,000$) which is the number of lines. The following $n$ lines contain four integers $x_0 \ \ y_0 \ \ x_1 \ \ y_1$ ($-1\,000\,000 \le x_0, \ y_0, \ x_1, \ y_1 \le 1\,000\,000$. Lines have non-zero length, i.e., the two points will be distinct: $x_0 \ne x_1$ or $y_0 \ne y_1$ or both.
Output the number of distinct points for which there is at least one pair of line segments that intersects or touches at this point.
Ignore those intersections points in your count that are created by line segments that intersect or touch at more than one point (i.e. overlapping segments).
You may further assume that if two line segments touch exactly at their endpoints, the three points involved are not collinear.
3 1 3 9 5 2 2 6 8 4 8 9 3
3
3 5 2 7 10 7 4 4 10 2 4 10 8
1
3 2 1 6 5 2 5 5 4 5 1 7 7
1
High School > Virginia Tech High School Programming Contest > 2017 Virginia Tech High School Programming Contest L번