当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2872:Another Snake

题目描述
In this problem, we consider a classic video game called ‘Snake’. If you don’t know what is, I’ll let all-round wikipedia explains to you.
The player controls a long, thin creature, resembling a snake, which roams around on a bordered plane, picking up food (or some other item), trying to avoid hitting its own tail or the "walls" that surround the playing area. Each time the snake eats a piece of food, its tail grows longer, making the game increasingly difficult. The user controls the direction of the snake's head (up, down, left, or right), and the snake's body follows. The player cannot stop the snake from moving while the game is in progress.
--Wikipedia
Recently, we downloaded a new version of Snake. This snake has infinity length, started at (0, 0). Snake can change direction counter-clockwise only at certain points, freely from 0 degree to 180 degrees (include 0 degree but not 180 degrees). Because Snake has infinity length, the total length appeared on screen grows longer and longer, that means, the tail of Snake always locates at (0, 0). The Snake wants to know the maximum pieces of food can be eaten. And, Snake will continue going forward after eating the last one, and it cannot hit itself.

Consider the condition below, after eat the last piece D, the Snake will hit himself. This condition should be considered illegal.

输入解释
The input contains multiple cases.
For each test case, the first line has one integer n(n<=15), indicates the number of points on the plane.
Following n lines, each line contains two integers, x and y describe the position of a piece of food.
输出解释
One line for each test case, contains one integer means the maximum number of food can be eaten.
输入样例
2
0 1
1 0
10
0 1
-1 0
0 -1
1 2
2 -2
-2 1
1 0
-1 -1
1 3
-3 -2
输出样例
2
10
提示
来自杭电HDUOJ的附加信息
Recommend gaojie

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-2872

最后修改于 2020-10-25T22:57:41+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
4000/2000MS(Java/Others) 65535/65535K(Java/Others)