PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#CC0000078. Đếm giao điểm các đoạn ngang dọc (Intersection Points)
HỌC THEO LỘ TRÌNH
2 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đếm giao điểm các đoạn ngang dọc (Intersection Points)
Intersection Points
Source: CSES
Version: Phuoc Hung OJ Extended
Problem Statement
Given horizontal or vertical segments, count their intersection points. No two parallel segments intersect, and no segment endpoint is an intersection point.
Input
The first line contains ; each following line contains describing a segment.
Output
Print the number of intersection points.
Subtasks
- Subtask 1 (20 points): ; ; ; endpoints differ; every segment is horizontal or vertical; parallel segments do not intersect; no endpoint is an intersection.
- Subtask 2 (30 points): ; ; ; endpoints differ; every segment is horizontal or vertical; parallel segments do not intersect; no endpoint is an intersection.
- Subtask 3 (50 points): ; ; ; endpoints differ; every segment is horizontal or vertical; parallel segments do not intersect; no endpoint is an intersection.
Examples
Input
3
2 3 7 3
3 1 3 5
6 2 6 6
Output
2
Explanation
The horizontal segment at intersects the vertical segments at and . Both intersections are strictly inside the segments; the answer is .