Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
把assign去掉,这里是STDIO的In Reply To:我的程序: Posted by:dfg at 2005-07-13 12:10:03 > Program cannon; > > Const fin ='cannon.in'; > fout ='cannon.out'; > > Var d,l,ld :array[1..100]of longint; > a :array[1..10]of boolean; > opt1,opt :array[1..100,1..100]of longint; > ch :char; > n,m,i,j,p,top,ans,s,max :longint; > > Function binva:longint; > var i,v:longint; > begin > v:=0; > for i:=1 to m do v:=v shl 1+ord(a[i]); > binva:=v; > end; > > Procedure search(p,r:longint); > begin > if r=0 then begin > inc(top); > d[top]:=binva; > l[top]:=i; > end > else if p<=m then begin > search(p+1,r); > a[p]:=true; > search(p+3,r-1); > a[p]:=false; > end; > end; > > Function ok(a,b:longint):boolean; > begin > ok:=(a>=b) and (a xor b=a-b); > end; > > Begin > {readin} > assign(input,fin); reset(input); > readln(n,m); > for i:=1 to n do begin > for j:=1 to m do begin > read(ch); > a[j]:=ch='P'; > end; > ld[i]:=binva; > readln; > end; > close(input); > {main} > {init} > top:=0; > fillchar(a,sizeof(a),0); > {dp} > if n=1 then ans:=(m-1) div 3+1 > else begin > for i:=0 to 4 do search(1,i); > for i:=1 to top do if ok(ld[1],d[i]) then > for j:=1 to top do if ok(ld[2],d[j]) then > if d[i] or d[j]=d[i]+d[j] then opt[i,j]:=l[i]+l[j]; > for s:=3 to n do begin > opt1:=opt; > for i:=1 to top do if ok(ld[s-1],d[i]) then > for j:=1 to top do if ok(ld[s],d[j]) and (d[i] or d[j]=d[i]+d[j]) then begin > max:=0; > for p:=1 to top do > if ok(ld[s-2],d[p]) and (d[p] or d[i] or d[j]=d[p]+d[i]+d[j]) then > if max<opt1[p,i]+l[j] then max:=opt1[p,i]+l[j]; > opt[i,j]:=max; > end; > end; > ans:=0; > for i:=1 to top do if ok(ld[n-1],d[i]) then > for j:=1 to top do if ok(ld[n],d[j]) and (d[i] or d[j]=d[i]+d[j]) then > if ans<opt[i,j] then ans:=opt[i,j]; > end; > {printout} > assign(output,fout); rewrite(output); > writeln(ans); > close(output); > End. Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator