#P2782. 友好城市
友好城市
Description
There is an east-west river with straight north and south banks. On each bank, there are cities at distinct positions. Each city on the north bank has exactly one friendly city on the south bank, and different cities have different friendly cities. Each pair of friendly cities applies to build a straight shipping lane across the river connecting the two cities. However, due to heavy fog on the river, the government decides to avoid any two lanes crossing to prevent accidents. Write a program to approve and reject some applications so that, while ensuring no two lanes cross, the number of approved applications is maximized.
Input Format
The first line contains an integer , the number of cities. From the second line to the -th line, each line contains two integers separated by a space, representing the coordinates of a pair of friendly cities on the south and north banks, respectively.
Output Format
Output a single line with one integer, the maximum number of applications the government can approve.
7
22 4
2 6
10 3
15 12
9 8
17 17
4 2
4
Hint
Constraints
- For of the testdata, , .
- For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号