|
|
back to boardWhy WA??? Var k,i,j,n:Byte; S:Array[1..10,1..1000] of Byte; SS:Array[1..10] of Integer; M:Array[1..10,1..10] of Boolean; W:Array[1..10] of Boolean; O:Array[1..10] of Byte; Len:Array[1..10] of Extended; ch:Char; fl,fl2:Boolean; Procedure rec(n:Byte); Var i:Byte; begin For i:=1 to SS[n] Do begin If S[n,i]>10 then Write(chr(S[n,i])) else If S[n,i] = 10 then WriteLn else rec(S[n,i]); end; end; begin ReadLn(n); For i:=1 to n Do begin W[i]:=False; Len[i]:=-1; end; For i:=1 to n Do For j:=1 to n Do M[i,j]:=False; i:=1; SS[1]:=0; While i<=n Do begin Read(ch); if ch = #13 then begin Read(ch); inc(SS[i]); S[i,SS[i]]:=10; end else if ch = '*' then begin Repeat Read(ch); Until ch in ['1'..'9']; inc(SS[i]); S[i,SS[i]]:=ord(ch)-ord('0'); M[i,S[i,SS[i]]]:=True; end else if ch = '#' then begin ReadLn; inc(i); SS[i]:=0; end else begin inc(SS[i]); S[i,SS[i]]:=ord(ch); end; end; For i:=1 to n Do begin fl:=False; For j:=1 to n Do begin fl2:=True; For k:=1 to n Do If M[j,k] AND (Len[k] = -1) then begin fl2:=False; break; end; If fl2 then begin fl:=True; Len[j]:=0; For k:=1 to SS[j] Do If S[j,k]>10 then Len[j] := Len[j]+1 else if S[j,k]=10 then Len[j ]:= Len[j]+2 else Len[j] := Len[j] + Len[S[j,k]]; If Len[1] > 0 then begin fl:=False; break; end; end; end; If NOT fl then break; end; If (Len[1] < -0.5)OR(Len[1]>1000000.5) then Write('#') else begin rec(1); end; end. |
|
|