/ Vijos / 讨论 / 分享 /

p1424 求助

const

p2:array[0..10]of integer=(1,2,4,8,16,32,64,128,256,512,1024);

var

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

f:array[1..100,1..100,1..100]of integer;

n,m,i,j,k,ans,z,j1,j2,j3:integer;

p:char;

procedure pre(st:string;now,last:integer);

var

t,i:integer;

begin

if now>m then

begin

inc(z);t:=0;

for i:=1 to length(st) do

if st[i]='1' then

begin

inc(t);

inc(a[z],p2[m-i]);

end;

anum[z]:=t;

exit;

end;

st:=st+'0';pre(st,now+1,last);

delete(st,length(st),1);

if now>(last+2) then

begin

st:=st+'1';

pre(st,now+1,now);

end;

end;

function max(a,b:integer):integer;

begin

if a>b then exit(a)

else exit(b);

end;

begin

readln(n,m);z:=0;ans:=0;

for i:=1 to n do

begin

k:=0;

for j:=1 to m do

begin

read(p);

if p='P' then inc(k,P2[m-j]);

end;

state[i]:=k;readln;

end;

pre('',1,-2);

for i:=1 to z do

if (state[1] or a[i])=state[1] then

f[1,i,1]:=anum[i];

for i:=2 to n do

for j1:=1 to z do

if (a[j1] or state[i])=state[i] then

for j2:=1 to n do

if (a[j1] and a[j2])=0 then

for j3:=1 to z do

if ((a[j1] and a[j3])=0)and((a[j2] and a[j3])=0) then

begin

f:=max(f,f+anum[j1]);

if f>ans then ans:=f;

end;

write(ans);

end.

为啥70分,有三个点总错误。

那位大牛能帮忙看看

0 条评论

目前还没有评论...