/ Vijos / 讨论 / 寻宝 /

HELP!!!!

var
n,m,i,j,x,k,ans:longint;
a:array[1..10000,0..100,0..1] of integer;
begin
readln(n,m);
for i:=1 to n do
for j:=0 to m-1 do
begin
read(x);
readln(a[i,j,x]);
end;
readln(x);
if a[1,x,0]>0 then ans:=a[1,x,0] else ans:=a[1,x,1];
k:=x; i:=1; j:=ans;
while i<=n do
begin
if a[i,k,1]>0 then
begin
if j-1=0 then
begin
inc(i);
if a[i,k,0]>0 then begin ans:=(ans+a[i,k,0]) mod 20123; j:=a[i,k,0]; end
else begin ans:=(ans+a[i,k,1]) mod 20123; j:=a[i,k,1]; end;
end
else dec(j);
end
else begin inc(k); if k>m then k:=0; end;
end;
writeln(ans);
end.

2 条评论

  • @ 2015-05-12 15:44:24

    我也错

  • @ 2015-05-12 15:44:12

    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

信息

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