Pagini recente » Cod sursa (job #3242667) | Cod sursa (job #1252093) | Cod sursa (job #2796456) | Cod sursa (job #993179) | Cod sursa (job #125186)
Cod sursa(job #125186)
var
n,i,j,t,f,l,li,nr:longint;
a:array[1..36000]of string;
fol:array[1..36000]of boolean;
alf:set of char;
term:boolean;
begin
readln(n);
for i:= 1 to n do
readln(a[i]);
for i:= 1 to n-1 do
begin
if not fol[i] then
begin
li:=length(a[i]);
for t:= 1 to li do
if not(a[i][t] in alf) then
alf:=alf+[a[i][t]];
for j:= i+1 to n do
if not fol[j] then
begin
l:=length(a[j]);
term:=false;f:=0;
if l=li then
begin
repeat
inc(f);
if not (a[j][f] in alf) then
term:=true;
until (term)or(f=l);
if not term then
begin
fol[j]:=true;
fol[i]:=true;
end;
end;
end;
end;
alf:=[];
end;
for i:= 1 to n do
if not fol[i] then
inc(nr);
writeln(nr);
end.