Dextrogyrate Camel
Time limit1sMemory limit512 MB
Find the longest closed camel route that starts at oasis 1 heading to oasis 2, always turns right by at most 180 degrees at each oasis, never crosses itself, and visits the most distinct oases.
- Level
Hard9 of 10
- Topics
- Geometry, Dynamic programming, Greedy, Sorting
- Solved
- No attempts yet
Problem
Byteotia has oasis in the desert, and no three of them lie on one straight line. Byteasar lives in one of the oasis and has a friend in every other one, and he wants to visit as many friends as possible while riding his camel. The camel is stubborn and moves in its own peculiar way:
- After leaving an oasis it travels in a straight line until it reaches another oasis.
- It changes direction only at an oasis, and there it always turns to the right (clockwise) by an angle in the interval . It makes exactly one turn at each oasis (it can never, for instance, turn by as the result of two consecutive turns).
- The route never touches or crosses itself, and the camel never travels along a segment it has already used. The only oasis the route may pass through twice is Byteasar's home, where the journey both begins and ends.
At the start the camel stands at Byteasar's home oasis already facing one particular oasis, and it must set off straight toward that oasis. The direction the camel faces once it has returned home is irrelevant.
Find a route that starts and ends at Byteasar's home and lets him visit as many friends as possible.
Input
The first line contains one integer () — the number of oasis, numbered from to . Byteasar lives in oasis , and his camel initially faces oasis . Each of the following lines describes one oasis: the -th of them contains two integers and (), the coordinates of oasis , separated by a single space.
Output
Print a single integer — the maximum number of friends Byteasar can visit. This equals the number of distinct oasis on the route other than his home oasis.
Hint
