荔园在线

荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀

[回到开始] [上一篇][下一篇]


发信人: kaman (天外飞仙), 信区: ACMICPC
标  题: 一道简单题~
发信站: 荔园晨风BBS站 (Thu Apr 15 12:45:29 2004), 站内信件

但要注意答案为0的判断^_^


The Tamworth Two
BOI '98? - Richard Forster
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.

PROGRAM NAME: ttwo
INPUT FORMAT
Lines 1-10:  Ten lines of ten characters each, as explained above

SAMPLE INPUT (file ttwo.in)
*...*.....
......*...
...*...*..
..........
...*.F....
*.....*...
...*......
..C......*
...*.*....
.*.*......

OUTPUT FORMAT
A single line with the integer number of minutes until Farmer John and
the cows meet. Print 0 if they will never meet.
SAMPLE OUTPUT (file ttwo.out)
49





--
Long long ago,there is a hero stand at the edge of the land,a sword in
hand.......
       ︵~`   ╭)                          ▁▁
      ︸ヾ)    (╯                        ▕天外▏
      ゞ7(  ︵  ))                        ▕飞仙▏
       ╰ ︶へ︶╯                          ▔▔
       ヅ╯  ジ〉

※ 来源:·荔园晨风BBS站 bbs.szu.edu.cn·[FROM: 192.168.111.200]


[回到开始] [上一篇][下一篇]

荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店