Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

问一个数据

Posted by lifeich1 at 2010-02-07 22:33:32 on Problem 1321
4 2
#...
##..
...#
..#.
某AC程序输出的是10
但应该是8吧。


附我的程序。。。(错误的)
var
    n,i,j,e,k1,k,ans:longint;
    u:array[0..1023] of integer;
    f,g:array[0..1023] of longint;
    a:array[0..10,0..10] of char;
begin
    readln(n,k1);
    while n>0 do begin
        e:=(1 shl n);
        fillchar(u,sizeof(u),false);
        for i:=0 to e do  begin
            j:=0;k:=i;
            while k>0 do begin
                if k and 1=1 then inc(j);
                k:=k shr 1;
            end;
            if j=k1 then u[i]:=1;
        end;
        for i:=1 to n do begin
            for j:=1 to n do read(a[i,j]);
            readln();
        end;
        fillchar(g,sizeof(g),0);
        fillchar(f,sizeof(f),0);
        g[0]:=1;
        ans:=0;
        for i:=1 to n do begin
            fillchar(f,sizeof(f),0);
            for j:=1 to n do begin
                if a[i,j]='.' then continue;
                for k:=0 to e do begin
                    if k and (1 shl (j-1))>0 then continue;
                    inc(f[k+(1 shl (j-1))],g[k]);
                end;
            end;
            for j:=0 to e do inc(g[j],f[j]);
        end;
        for j:=0 to e do if u[j]=1 then inc(ans,g[j]);
        writeln(ans);
        readln(n,k1);
    end;
end.

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator