Problem A. Smart Blueprint
Xem dạng PDFTrong trường hợp đề bài hiển thị không chính xác, bạn có thể tải đề bài tại đây: Đề bài
As part of the "Smart Campus" initiative at UMT University, a senior student team is digitising every engineering blueprint of the underground infrastructure. After scanning the legacy drawings, they recovered a large collection of straight-line segments-each one representing a stretch of pipe, buried cable, or power line. Because different construction crews often redrew the same objects, many of these segments lie on the same infinite line and overlap one another wholly or partially.
To simplify the blueprint, the team must keep the minimum number of distinct segments that still preserves all information. Two segments are said to overlap if they lie on the same straight line and have an intersection of positive length.
Input
The input consists of multiple test cases. Each test case begins with an integer ~n (1 ≤ n ≤ 10^4)~ - the number of line segments in the map.
Then follow n lines, each containing 4 real numbers: ~x_1, y_1, x_2, y_2~ which represent the two endpoints of a line segment.
• Coordinates are in the range [0, 1000], with up to 2 decimal places.
• No segment has zero length.
• The input ends with a line containing a single 0 - this line should not be processed.
Output
For every test case, output a single line with one integer - the minimum number of distinct segments that must remain.
Sample Input 1
3
1.0 10.0 3.0 14.0
0.0 0.0 20.0 20.0
10.0 28.0 2.0 12.0
2
0.0 0.0 1.0 1.0
1.0 1.0 2.15 2.15
2
0.0 0.0 1.0 1.0
1.0 1.0 2.15 2.16
0
Sample Ouput 1
2
1
2
Bình luận