{ fp } {* * Problem : SUBSTR * Contest : UOI-2006 (Dnepropetrovsk) * Type : Solution * Date : April 1, 2006 * Author : Sergey Savchuk * Language : Pascal * Compiler : Free Pascal * Algorithm: Slow solution without read optimization *} Var fo: Text; fi: File of char; a:array['a'..'z'] of Longint; i: longint; ch: char; S:String; ls: byte absolute s; M:String; lm: byte absolute m; Begin Assign(fi,'SUBSTR.DAT'); Reset(fi); For i:=1 to filesize(fi) do Begin Read(fi,ch); if ch<'a' Then continue; if a[ch]<>0 Then Delete(S,1,pos(ch,S)); a[ch]:=i; S:=S+ch; if ls>lm Then M:=S End; Assign(fo,'SUBSTR.SOL'); ReWrite(fo); Writeln(fo,M); Close(fo) End.