Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
wa疯了!!纯暴力不知WA哪..求数据..var s:array[1..4000] of string; a:array[1..10] of string; f:array[1..4000] of string; k,m,n,c,i:longint; procedure init; var i:longint; begin readln(n); for i:=1 to n do readln(a[i]); end; procedure task1; var i,j:longint; x,y:string; begin x:=a[1]; k:=0; for i:=1 to length(x) do begin y:=''; for j:=i to length(x) do begin y:=y+x[j]; if length(y)>=2 then begin inc(k);s[k]:=y; end; end; end; end; procedure dfs(const x:string; j:longint); begin if (j=n)and(pos(x,a[j])<>0)then begin inc(c);f[c]:=x;exit;end; if pos(x,a[j])=0 then exit else dfs(x,j+1); end; procedure sort; var i,j:longint; x,y:string; f1:boolean; begin for i:=1 to c do for j:=i+1 to c do if length(f[i])<length(f[j]) then begin y:=f[i]; f[i]:=f[j]; f[j]:=y; end; for i:=1 to c do if length(f[i])<>length(f[i+1]) then begin c:=i;break;end; for i:=1 to c do begin if f[1]>f[i] then f[1]:=f[i]; end; if f[1]='' then writeln('no significant commonalities') else writeln(f[1]); end; procedure main; var i:longint; begin c:=0; for i:=1 to k do begin dfs(s[i],2); end; end; begin readln(m); for i:=1 to m do begin init; task1; main; sort; end; end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator