帮忙 大牛

var

pi,pj,pjj,fz,pp:longint;

n,m,i,j:integer;

kk:array[1..10000] of integer;

ff:array[1..1024] of boolean;

a:array[1..100,1..10] of integer;

ll:array[1..1024,1..10] of integer;

function mm(x:integer):longint;

var i:integer;

begin

mm:=1;

for i:=1 to x-1 do

mm:=mm*2;

end;

begin

readln(n);

readln(m);

for i:=1 to m do

begin

for j:=1 to n do

read(a);

readln;

end;

fz:=0;

for i:=1 to n do

fz:=fz+mm(i);

fillchar(ll,sizeof(ll),0);

fillchar(kk,sizeof(kk),0);

fillchar(ff,sizeof(ff),false);

pi:=0; pj:=1; kk[1]:=0;

repeat

inc(pi); pjj:=pj;

for i:=1 to m do

begin

pp:=0;

for j:=1 to n do

if (ll[pjj,j]=1)or(a=1)

then pp:=pp+mm(j);

if not ff[pp]

then begin

ff[pp]:=true;

if ff[fz]

then begin

writeln(kk[pjj]+1);

halt;

end;

inc(pj);

for j:=1 to n do

if (ll[pjj,j]=1)or(a=1)

then ll[pj,j]:=1

else ll[pj,j]:=0;

kk[pj]:=kk[pjj]+1;

end;

end;

until pi>pj;

writeln('The patient will be dead.');

end.

0 条评论

目前还没有评论...

信息

ID
1026
难度
6
分类
搜索 | 搜索与剪枝 点击显示
标签
(无)
递交数
3669
已通过
1112
通过率
30%
被复制
20
上传者