|
|
back to boardWA1 I have correct results on my comp, but Judge return WA1. What's wrong? Program z1019; Type Chain=^Elem; Elem= Record point:LongInt; color:Boolean; next:Chain; End; Var count,i,st,en:LongInt; col:Boolean; col_char:Char; ch:Chain; Procedure FirstStep(Var c:Chain); Var temp:Chain; Begin New(c); c^.point:=0; c^.color:=True; new(c^.next); temp:=c^.next; temp^.point:=1000000000; temp^.color:=True; temp^.next:=nil; End; Procedure InsertLine(Var c:Chain; s,e:LongInt; co:Boolean); Var strt,strt_p,en,en_p,temp:Chain; tcol:Boolean; Begin strt:=c^.next; strt_p:=c; While strt^.point<s Do Begin strt:=strt^.next; strt_p:=strt_p^.next; End; en:=c; While en^.point<e Do Begin tcol:=en^.color; en:=en^.next; End; strt:=strt_p; if en^.point=e Then Begin End Else Begin new(temp); temp^.point:=en^.point; temp^.next:=en^.next; temp^.color:=en^.color; en^.color:=tcol; en^.point:=e; en^.next:=temp; End; If strt^.point=s Then Begin strt^.color:=co; End Else Begin new(temp); temp^.next:=strt^.next; strt^.next:=temp; temp^.point:=s; temp^.color:=co; strt:=temp; End; While strt^.next<>en Do Begin temp:=strt^.next; strt^.next:=temp^.next; dispose(temp); End; strt:=c; temp:=c^.next; While temp<>nil Do Begin If (strt^.color=temp^.color) And (temp^.point<>1000000000) Then Begin strt_p:=temp; temp:=temp^.next; dispose(strt_p); strt^.next:=temp End Else Begin strt:=strt^.next; temp:=temp^.next; End; End; End; Procedure Solve(c:Chain); Var max,max_n,max_m,now:LongInt; Begin max:=0; max_n:=0; max_m:=0; While c^.next<>nil Do Begin If c^.Color Then Begin now:=c^.next^.Point-c^.Point; If now>max Then Begin max:=now; max_n:=c^.Point; max_m:=c^.next^.point; End; End; c:=c^.next; End; WriteLn(max_n,' ',max_m); End; BEGIN ReadLn(count); FirstStep(ch); For i:=1 To count Do Begin ReadLn(st,en,col_char); If col_char='w' Then col:=True Else col:=False; If st<>en Then InsertLine(ch,st,en,col); End; Solve(ch); END. Re: WA1 It's space) Bad,bad space % |
|
|