#4049: 为什么?求助


cfjhzcb (cfjhzcb)

學校 : Harvard University
編號 : 9545
來源 : [122.96.58.35]
最後登入時間 :
2010-11-12 19:09:19
d703. SOS ~~~ | From: [122.96.58.35] | 發表日期 : 2010-07-31 14:35

*** 第 1 點 (20%):AC (8ms, 6.5MB)

*** 第 2 點 (20%):AC (12ms, 6.5MB)

*** 第 3 點 (20%):AC (8ms, 6.5MB)

*** 第 4 點 (20%):AC (20ms, 6.5MB)

*** 第 5 點 (20%):WA (line:254)
您的答案為: LLLLLSSLLLLLLSSLLSLL
正確答案為: SSSSSSSLLLLLLSSLLSLL

 

我的程序:

program d703;
type
  atype=array[0..100] of integer;
var
  b:array[0..10,0..10] of array[1..252] of atype;
  c:array[0..10,0..10] of boolean;
  d:array[0..10,0..10] of integer;
  a:atype;
  m,n,l,i,j,k,t:integer;
  f:boolean;
begin
  f:=true;
  fillchar(b,sizeof(b),0);
  fillchar(c,sizeof(c),false);
  fillchar(d,sizeof(d),0);
  while not eof do begin if not f then writeln; f:=false;
  readln(m,n);
  if c[m,n] then
    for i:=1 to d[m,n] do
      begin
        for j:=1 to m+n do
          if b[m,n,i,j]=1 then write('S') else write('L');
        writeln;
      end
  else begin
  c[m,n]:=true;
  l:=m+n;
  a[0]:=0;
  for i:=1 to m do a[i]:=1;
  for i:=m+1 to l do a[i]:=2;
  while a[0]=0 do
    begin
      d[m,n]:=d[m,n]+1;
      b[m,n,d[m,n]]:=a;
      for i:=1 to l do if a[i]=1 then write('S') else write('L'); writeln;
      j:=l-1;
      while a[j]>=a[j+1] do j:=j-1;
      k:=l;
      while a[j]>=a[k] do k:=k-1;
      t:=a[j];a[j]:=a[k];a[k]:=t;
      for i:=j+1 to (j+l+1) div 2 do
        begin
          t:=a[i];a[i]:=a[j+l+1-i];a[j+l+1-i]:=t;
        end;
    end;     end;                                end;
end.


用全排列+记忆化做的 为什么不对?

 

 
ZeroJudge Forum