영어 원문입니다. 원문의 수식·표를 글자로 옮겨 모양이 다를 수 있습니다. 정확한 내용은 원문 페이지에서 확인하세요. 원문 페이지 열기 (새 창)
시간 제한 1초 · 메모리 제한 512 MB
Problem
Given n horizontal and vertical line segments, your task is to calculate the number of their intersection points.
You can assume that no parallel line segments intersect, and no endpoint of a line segment is an intersection point.
Input
The first line has an integer n: the number of line segments.
Then there are n lines describing the line segments. Each line has four integers: x_1, y_1, x_2 and y_2: a line segment begins at point (x_1,y_1) and ends at point (x_2,y_2).
Output
Print the number of intersection points.
Constraints
- 1 ≤ n ≤ 10^5
- -10^6 ≤ x_1 ≤ x_2 ≤ 10^6
- -10^6 ≤ y_1 ≤ y_2 ≤ 10^6
- (x_1,y_1) ≠ (x_2,y_2)
예제
예제 1
3 2 3 7 3 3 1 3 5 6 2 6 6
2