记录编号 |
326393 |
评测结果 |
ATAAAAATTA |
题目名称 |
为爱追寻 |
最终得分 |
70 |
用户昵称 |
小怪兽 |
是否通过 |
未通过 |
代码语言 |
Pascal |
运行时间 |
8.545 s |
提交时间 |
2016-10-21 07:42:09 |
内存使用 |
49.76 MiB |
显示代码纯文本
var n,x0,y0,xt,yt,i,dx,dy,ans:longint;
zb:array[0..1000100,1..2] of longint;
q:array[0..1000100] of longint;
h:array[0..10001007] of longint;
mo:int64;
procedure hash(t:longint);
var k:int64;
x,y,next:longint;
begin
x:=zb[t,1];y:=zb[t,2];
k:=((x*y mod mo)+mo) mod mo;
next:=h[k];
while next<>0 do
begin
if (zb[next,1]=x)and(zb[next,2]=y) then exit;
next:=q[next];
end;
inc(ans);
q[t]:=h[k];
h[k]:=t;
end;
begin
assign(input,'loverfinding.in');
assign(output,'loverfinding.out');
reset(input);
rewrite(output);
mo:=10000007;
read(n,x0,y0,xt,yt);
zb[1,1]:=x0;
zb[1,2]:=y0;
hash(1);
for i:=2 to n+1 do
begin
if (zb[i-1,1]=xt)and(zb[i-1,2]=yt) then break;
read(dx,dy);
zb[i,1]:=zb[i-1,1]+dx;
zb[i,2]:=zb[i-1,2]+dy;
hash(i);
end;
writeln(ans);
close(input);
close(output);
end.