77 人解决,151 人已尝试。
113 份提交通过,共有 440 份提交。
4.8 EMB 奖励。
单点时限: 2.0 sec
内存限制: 256 MB
Tom & Jerry can move in the rectangle(10*10),here is a example:
….....
......*…
……..
..........
…*.C....
.....…
…*......
..M......*
….....
........
C symbolise the cat
M symbolise the mouse
. symbolise freeland(where tom & jerry can move)
Each second Tom & Jerry can move one step. If they are in the same place we call it “encouter”.
What you should pay attetion is the case that if they “swith”(Tom & Jerry simultaneously move a step which will swith their position,see if Tom is at the point A & Jerry is at the point B at first,and after they move their steps their position turn out to be Tom is at the point B & Jerry is at the point A)IS NOT “encouter”
The principle of their moving:most cases they move directly and if there is a obstacle in his way or the next step will be the border they will use 1 second to turn right.
They face north at the beginning
There are many test cases,The frist rows is the case.the next is the each case.Each case have 10 rows!
a integer T:the time they “encounter”,if they has never met at all output -1
1 *...*..... ......*... ...*...*.. .......... ...*.C.... *.....*... ...*...... ..M......* ...*.*.... .*.*......
49