← 返回 uber 的题目列表Street (Line) with the Most Stations
类型:online_judge
You are given a list of 2D points coordinates, where each point represents a station. A street is defined as a straight line, and streets are restricted to the following orientations:
Horizontal (all points share the same y)
Vertical (all points share the same x)
Diagonal direction (points lie on the same diagonal; a common restriction is slope +1 or -1)
Find a street that contains the maximum number of stations, and output all station coordinates on that street (any order is fine. If multiple streets tie for maximum, return any one of them).
Input
Line 1: integer n, the number of stations
Next n lines: two integers x y, the coordinates of a station
Output
Line 1: integer k, the number of stations on the chosen street
Next k lines: the station coordinates x y
Constraints (typical interview assumptions)
1 <= n <= 2e5
Coordinates fit in 32-bit signed integers
Example
Input:
6
0 0
1 1
2 2
0 1
0 2
2 0
Output (one possible answer):
3
0 0
1 1
2 2
Example
Input
6
0 0
1 1
2 2
0 1
0 2
2 0
Output
3
0 0
1 1
2 2