21904_AnotherSnake

2022-5-16 18:20| 发布者: Hocassian| 查看: 24| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-4-89505945473300-Problem List-采集的数据-后羿采集器.html

Pro.ID

21904

Title

Another Snake

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21904

AC

14

Submit

64

Ratio

21.88%

时间&空间限制

  • Time Limit: 4000/2000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    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.

    输出

    Description

    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.

    Input

    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.

    Output

    One line for each test case, contains one integer means the maximum number of food can be eaten.

    Sample Input

    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

    Sample Output

    2
    10

    Hint


    Source

    样例输入

    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

    提示



    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部