#P2831. [NOIP 2016 提高组] 愤怒的小鸟

    ID: 1869 远端评测题 2000ms 500MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>搜索2016NOIp 提高组状态压缩,状压

[NOIP 2016 提高组] 愤怒的小鸟

Description

Kiana has recently become addicted to a magical game.

Simply put, this game takes place on a plane.

There is a slingshot at (0,0) (0, 0) . Each time, Kiana can use it to launch a red bird toward the first quadrant. The flight trajectory of a bird is a curve of the form y=ax2+bx y = a x^2 + b x , where a,b a, b are parameters chosen by Kiana and must satisfy a<0 a < 0 , with a,b a, b being real numbers.

When a bird falls back to the ground (i.e., the x x -axis), it disappears instantly.

In a certain level of the game, there are n n green pigs in the first quadrant of the plane. The i i -th pig is at coordinates (xi,yi) \left( x_i, y_i \right) .

If a bird’s trajectory passes through (xi,yi) \left( x_i, y_i \right) , then the i i -th pig will be eliminated, and the bird will continue along its original trajectory. If a bird’s trajectory does not pass through (xi,yi) \left( x_i, y_i \right) , then that bird’s entire flight has no effect on the i i -th pig.

For example, if two pigs are at (1,3) (1, 3) and (3,3) (3, 3) , Kiana can choose to launch a bird with trajectory y=x2+4x y = -x^2 + 4x , and both pigs will be eliminated by this bird.

The goal of the game is to eliminate all the pigs by launching birds.

Each level of this magical game is difficult for Kiana, so she also entered some mysterious commands to make it easier to complete the game. These commands are detailed in Input Format.

Assume the game has T T levels. Now Kiana wants to know, for each level, the minimum number of birds needed to eliminate all the pigs. Since she cannot compute it herself, she hopes you will tell her.

Input Format

The first line contains a positive integer T T , the total number of levels in the game.

Then, for each of the T T levels, the first line contains two non-negative integers n,m n, m , representing the number of pigs in that level and the type of mysterious command Kiana entered, respectively. The next n n lines each contain two positive real numbers xi,yi x_i, y_i , indicating that the i i -th pig is at (xi,yi) (x_i, y_i) . It is guaranteed that no two pigs in the same level share identical coordinates.

If m=0 m = 0 , it means Kiana entered a command that has no effect.

If m=1 m = 1 , then this level satisfies: at most n/3+1 \lceil n / 3 + 1 \rceil birds are sufficient to eliminate all pigs.

If m=2 m = 2 , then this level satisfies: there is an optimal solution in which one bird eliminates at least n/3 \lfloor n / 3 \rfloor pigs.

It is guaranteed that 1n18 1 \leq n \leq 18 , 0m2 0 \leq m \leq 2 , and 0<xi,yi<10 0 < x_i, y_i < 10 . All real numbers in the input are given to two decimal places.

In the above, the symbols c \lceil c \rceil and c \lfloor c \rfloor denote the ceiling and floor of c c , respectively. For example: $\lceil 2.1 \rceil = \lceil 2.9 \rceil = \lceil 3.0 \rceil = \lfloor 3.0 \rfloor = \lfloor 3.1 \rfloor = \lfloor 3.9 \rfloor = 3$.

Output Format

For each level, output one line with a positive integer: the minimum number of birds needed to eliminate all pigs in that level.

2
2 0
1.00 3.00
3.00 3.00
5 2
1.00 5.00
2.00 8.00
3.00 9.00
4.00 8.00
5.00 5.00
1
1
3
2 0
1.41 2.00
1.73 3.00
3 0
1.11 1.41
2.34 1.79
2.98 1.49
5 0
2.72 2.72
2.72 3.14
3.14 2.72
3.14 3.14
5.00 5.00
2
2
3

1
10 0
7.16 6.28
2.02 0.38
8.33 7.78
7.68 2.09
7.46 7.86
5.77 7.44
8.24 6.72
4.42 5.11
5.42 7.79
8.15 4.99
6

Hint

Sample Explanation 1.

There are two levels in this set of testdata.

In the first level, as in the Description, 2 2 pigs are at (1.00,3.00) (1.00, 3.00) and (3.00,3.00) (3.00, 3.00) . Launching one bird with trajectory y=x2+4x y = -x^2 + 4x is enough to eliminate them.

In the second level, there are 5 5 pigs, and by observation they all lie on the parabola y=x2+6x y = -x^2 + 6x , so Kiana needs to launch only one bird to eliminate all pigs.

Constraints

Test point ID nn\leqslant m=m= TT\leqslant
11 22 00 1010
22 3030
33 33 1010
44 3030
55 44 1010
66 3030
77 55 1010
88 66
99 77
1010 88
1111 99 3030
1212 1010
1313 1212 11
1414 22
1515 1515 00 1515
1616 11
1717 22
1818 1818 00 55
1919 11
2020 22

Translated by ChatGPT 5