记录编号 |
266644 |
评测结果 |
WWWWWAWAW |
题目名称 |
[USACO 2.4]两只塔姆沃斯牛 |
最终得分 |
22 |
用户昵称 |
ConanQZ |
是否通过 |
未通过 |
代码语言 |
Pascal |
运行时间 |
0.001 s |
提交时间 |
2016-06-08 20:02:44 |
内存使用 |
0.32 MiB |
显示代码纯文本
program P1135;
var
xx:array[1..4]of longint;
yy:array[1..4]of longint;
time,fa,fb,ax,ay,bx,by,tot,x,y,i:longint;
map:array[0..11,0..11]of integer;
p:array[1..10,1..10,1..4,1..10,1..10,1..4]of boolean;
c:char;
begin
//assign(input,'11.in'); reset(input);
xx[1]:=-1; xx[3]:=1;
yy[2]:=1; yy[4]:=-1;
assign(input,'ttwo.in'); reset(input);
assign(output,'ttwo.out'); rewrite(output);
while not eof do
begin
read(c);
if (c<>#10){and(c<>#10)} then
begin
inc(tot);
if tot mod 10=0 then x:=tot div 10 else x:=tot div 10+1;
if tot mod 10=0 then y:=10 else y:=tot-(x-1)*10;
if c='*' then map[x,y]:=1
else if c='F' then
begin
ax:=x; ay:=y;
end
else if c='C' then
begin
bx:=x; by:=y;
end;
end;
end;
for i:=1 to 10 do
begin
map[0,i]:=1;
map[11,i]:=1;
map[i,0]:=1;
map[i,11]:=1;
end;
fa:=1; fb:=1;
while (ax<>bx)or(ay<>by) do
begin
//if time=49 then break;
if p[ax,ay,fa,bx,by,fb] then
begin
writeln(0);
halt;
end
else p[ax,ay,fa,bx,by,fb]:=true;
inc(time);
if (map[ax+xx[fa],ay+yy[fa]]<>1) then
begin
inc(ax,xx[fa]);
inc(ay,yy[fa]);
end
else
begin
inc(fa);
if fa=5 then fa:=1;
end;
if (map[bx+xx[fb],by+yy[fb]]<>1) then
begin
inc(bx,xx[fb]);
inc(by,yy[fb]);
end
else
begin
inc(fb);
if fb=5 then fb:=1;
end;
//writeln(ax,' ',ay,' ',bx,' ',by);
end;
writeln(time);
end.