/ Vijos / 讨论 / 寻宝 /

归来

var i,j,sam,count,qwe,n,m:longint;
a,b:array[1..10000,0..100]of longint;

procedure print;
begin
writeln(count); {close(input);close(output);}
halt;
end;

procedure pre(p:longint);
begin
if p=n+1 then print;
count:=(count+b[p,sam]) mod 20123;
while a[p,sam]=0 do begin inc(sam);if sam=m then sam:=0; end;
qwe:=b[p,sam];
while qwe>0 do begin inc(sam);if sam=m then sam:=0;
if a[p,sam]=1 then dec(qwe);
end;
pre(p+1);
end;

begin
{assign(input,'p1787.in');reset(input);
assign(output,'p1787.out');rewrite(output);}
readln(n,m);
for i:=1 to n do
begin
for j:=0 to m-1 do
begin
readln(a[i,j],b[i,j]);
end;
end;
readln(sam);
pre(1);
end.

求大神赐教~

1 条评论

  • @ 2015-05-12 16:14:11

    var i,j,sam,count,qwe,n,m,p:longint;
    a,b:array[1..10000,0..100]of longint;

    procedure print;
    begin
    writeln(count); {close(input);close(output);}
    halt;
    end;
    begin
    {assign(input,'p1787.in');reset(input);
    assign(output,'p1787.out');rewrite(output);}
    readln(n,m);
    for i:=1 to n do
    begin
    for j:=0 to m-1 do
    begin
    readln(a[i,j],b[i,j]);
    end;
    end;
    readln(sam);

    for p:=1 to n do
    begin

    if p=n+1 then print;

    count:=(count+b[p,sam]) mod 20123;qwe:=b[p,sam];

    for i:=1 to qwe do
    begin
    while a[p,sam]=0 do begin inc(sam);if sam=m then sam:=0; end;
    if i<>qwe then begin inc(sam);if sam=m then sam:=0; end;
    end;

    end;

    print;
    end.
    这个50,超时了
    众位可否指点?

  • 1

信息

ID
1787
难度
6
分类
模拟 点击显示
标签
递交数
2640
已通过
618
通过率
23%
被复制
17
上传者