WRONG ANSWER?WHY?

错了第五组数据,为什么?

type

point=^node;

node=record

num:longint;

next:point;

end;

var

p:point;

used:array[0..1023] of boolean;

d:array[0..1023] of longint;

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

c:array[1..10] of integer;

i,ii,j,n,m,y,k:Longint;

head:array[0..1023] of point;

procedure dfs(t,v:longint);

var p:point;

begin

used[t]:=true;d[t]:=v;

new(p);p:=head[t]^.next;

while pnil do

begin

if (not used[p^.num]) or ((used[p^.num]) and (d[p^.num]>v+1)) then dfs(p^.num,v+1);

p:=p^.next;

end;

end;

begin

assign(input,'1.in');reset(input);

assign(output,'1.out');rewrite(output);

readln(m);readln(n);

for i:=1 to n do

begin

for j:=1 to m do read(b);readln;

end;

for i:=0 to 1 shl m-1 do begin new(head[i]);head[i]^.next:=nil;end;

for i:=1 shl m-1 downto 0 do

for j:=1 to n do

begin

ii:=i;

for k:=1 to m do

begin

c[m-k+1]:=ii mod 2;ii:=ii div 2;

end;

for k:=1 to m do

begin

if (b[j,k]=-1) and (c[k]=0) then c[k]:=1;

if (b[j,k]=1) and (c[k]=1) then c[k]:=0;

end;

y:=0;for k:=1 to m do y:=y+c[k]*(1 shl (k-1));

new(p);p^.num:=y;p^.next:=head[i]^.next;head[i]^.next:=p;

end;

fillchar(used,sizeof(used),false);

fillchar(d,sizeof(d),0);

dfs(1 shl m-1,0);

if not used[0] then writeln('The patient will be dead.') else writeln(d[0]);

close(input);close(output);

end.

请大牛看看。或者能不能提供第五组数据?

0 条评论

目前还没有评论...

信息

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