#T32. 友好城市
友好城市
Description
The country of Palmia has a great river that runs from east to west, with straight north and south banks. Each bank has N cities located at distinct positions. Every city on the north bank has exactly one "sister city" on the south bank, and no two cities share the same sister city. Each pair of sister cities has applied to the government to open a straight shipping route across the river connecting them. However, due to heavy fog on the river, the government has decided to avoid any intersecting routes to prevent accidents.
Write a program to help the government approve or reject applications in such a way that no two approved routes intersect, while maximizing the number of approved applications.
Input Format
- Line 1: An integer N (1 ≤ N ≤ 5000), representing the number of cities.
- Lines 2 to N+1: Each line contains two integers separated by a single space, representing the coordinates of a pair of sister cities on the south and north banks, respectively. (0 ≤ xi ≤ 10000)
Output Format
A single integer, representing the maximum number of applications the government can approve without any intersecting routes.
7
22 4
2 6
10 3
15 12
9 8
17 17
4 2
4