10145_TheTamworthTwo

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

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

Pro.ID

10145

Title

The Tamworth Two

Title链接

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

AC

20

Submit

40

Ratio

50.00%

时间&空间限制

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

    A pair of cows is loose somewhere in the forest. Farmer John is lending his expertise to their capture. Your task is to model their behavior.

    The chase takes place on a 10 by 10 planar grid. Squares can be empty or they can contain:

    • an obstacle,

    • the cows (who always travel together), or

    • Farmer John.

    The cows and Farmer John can occupy the same square (when they 'meet') but neither the cows nor Farmer John can share a square with an obstacle.

    Each square is
    represented
    as follows:

    • .  Empty square    

    • *  Obstacle

    • C  Cows

    • F  Farmer

    Here is a sample grid:

    *...*.....
    ......*...
    ...*...*..
    ..........
    ...*.F....
    *.....*...
    ...*......
    ..C......*
    ...*.*....
    .*.*......

    The cows wander around the grid in a fixed way. Each minute, they either move forward or rotate. Normally, they move one square in the direction they are facing. If there is an obstacle in the way or they would leave the board by walking `forward', then they spend the entire minute rotating 90 degrees clockwise.

    Farmer John, wise in the ways of cows, moves in exactly the same way.

    The farmer and the cows can be considered to move simultaneously during each minute. If the farmer and the cows pass each other while moving, they are not considered to have met. The chase ends when Farmer John and the cows occupy the same square at the end of a minute.

    Read a ten-line grid that represents the initial state of the cows, Farmer John, and obstacles. Each of the ten lines contains exactly ten characters using the coding above. There is guaranteed to be only one farmer and one pair of cows. The cows and Farmer John will not initially be on the same square.

    Calculate the number of minutes until the cows and Farmer John meet. Assume both the cows and farmer begin the simulation facing in the 'north' direction. Print 0 if they will never meet.

    输入

    Mutiple tese cases, first line is an integer T, indecating the number of test case. for each case:

    Lines 1-10:  Ten lines of ten characters each, as explained above.

    输出

    Description

    A pair of cows is loose somewhere in the forest. Farmer John is lending his expertise to their capture. Your task is to model their behavior.

    The chase takes place on a 10 by 10 planar grid. Squares can be empty or they can contain:

    • an obstacle,

    • the cows (who always travel together), or

    • Farmer John.

    The cows and Farmer John can occupy the same square (when they 'meet') but neither the cows nor Farmer John can share a square with an obstacle.

    Each square is
    represented
    as follows:

    • .  Empty square    

    • *  Obstacle

    • C  Cows

    • F  Farmer

    Here is a sample grid:

    *...*.....
    ......*...
    ...*...*..
    ..........
    ...*.F....
    *.....*...
    ...*......
    ..C......*
    ...*.*....
    .*.*......

    The cows wander around the grid in a fixed way. Each minute, they either move forward or rotate. Normally, they move one square in the direction they are facing. If there is an obstacle in the way or they would leave the board by walking `forward', then they spend the entire minute rotating 90 degrees clockwise.

    Farmer John, wise in the ways of cows, moves in exactly the same way.

    The farmer and the cows can be considered to move simultaneously during each minute. If the farmer and the cows pass each other while moving, they are not considered to have met. The chase ends when Farmer John and the cows occupy the same square at the end of a minute.

    Read a ten-line grid that represents the initial state of the cows, Farmer John, and obstacles. Each of the ten lines contains exactly ten characters using the coding above. There is guaranteed to be only one farmer and one pair of cows. The cows and Farmer John will not initially be on the same square.

    Calculate the number of minutes until the cows and Farmer John meet. Assume both the cows and farmer begin the simulation facing in the 'north' direction. Print 0 if they will never meet.

    Input

    Mutiple tese cases, first line is an integer T, indecating the number of test case. for each case:

    Lines 1-10:  Ten lines of ten characters each, as explained above.

    Output

    For each case, output a single line with the integer number of minutes until Farmer John and the cows meet. Print 0 if they will never meet.

    Sample Input

    1
    *...*.....
    ......*...
    ...*...*..
    ..........
    ...*.F....
    *.....*...
    ...*......
    ..C......*
    ...*.*....
    .*.*......


    Sample Output

    49

    Source

    样例输入

    1
    *...*.....
    ......*...
    ...*...*..
    ..........
    ...*.F....
    *.....*...
    ...*......
    ..C......*
    ...*.*....
    .*.*......


    样例输出

    49

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部