Coin Slider
Time limit2sMemory limit512 MB
Choose the largest subset of at most 16 coins and an order of moves so no moving coin ever collides with a stationary or already-moved coin.
- Level
Hard8 of 10
- Topics
- Geometry, Bit manipulation, Dynamic programming, Greedy
- Solved
- No attempts yet
Problem
You are playing a coin puzzle. The rules are as follows.
There are coins on a table. The -th coin is a circle of radius , and its center is initially at . Each coin also has a target position: you have to move the -th coin so that its center is at . You move coins one at a time, and you can move each coin at most once. When you move a coin, it travels from its initial position to its target position along a straight line. In addition, coins must never collide with each other, including in the middle of a move.
The score of the puzzle is the number of coins you move from their initial positions to their target positions. Write a program that determines the maximum score for the given puzzle.
Input
The input consists of a single test case in the following format.
N
r1 sx1 sy1 tx1 ty1
.
.
.
rN sxN syN txN tyN
The first line contains an integer (), the number of coins in the puzzle. The -th of the following lines contains five integers , , , , and (, , ). is the radius of the -th coin, is its initial position, and is its target position.
At their initial positions, no two coins touch or overlap. You can also assume that the maximum score does not change even if the radius of every coin changes by .
Output
Print the maximum score of the given puzzle on a single line.
Hint
In the first example, the third coin cannot move because the other two coins are in its way.

Example 1. Initial positions

Example 1. After the moves