- 教主的游乐场
- 2013-09-17 20:04:59 @
Program p1417;
Var i,j,k,m,n:longint;
q,p:boolean;
a,f,t1:array[1..1000000] of longint;
t2:array[1..1000000] of 0..1;
d:array[1..40000] of longint;
Procedure inputbox;
begin
readln(n,m);
for i:=1 to n do
read(a[i]);
readln;
for i:=1 to m do
read(d[i]);
end;
Procedure work;
begin
fillchar(t2,sizeof(t2),0);
fillchar(f,sizeof(f),0);
j:=0;
q:=false; p:=true;
for i:=1 to n do
begin
if a[i]+i>n then
begin
f[i]:=1;
if not q then j:=i;
q:=true;
end else
if q then f[i]:=2 else p:=false;
end;
q:=false;
if not p then
for i:=j downto 1 do
begin
if a[i]+i>n then
k:=i else
begin
if a[i]+i>=k then f[i]:=2 else
f[i]:=1+f[i+a[i]];
end;
end;
end;
Procedure print;
begin
for i:=1 to m-1 do
write(f[d[i]],' ');
writeln(f[d[m]]);
end;
Begin
inputbox;
work;
print;
End.
2 条评论
-
twd2 LV 9 MOD @ 2013-09-19 19:18:35
数组越界?
-
2013-09-17 20:05:59@
只过前两数据
最后三个运行时错误
- 1