Pagini recente » Cod sursa (job #1061582) | Cod sursa (job #669465) | Cod sursa (job #298658) | Cod sursa (job #2187801) | Cod sursa (job #125604)
Cod sursa(job #125604)
var f1,f2:text;
i,n,m,dimh,h,nr,j,el:longint;
aux2:string[20];
s:array[0..36010] of string[20];
c:array[0..30] of longint;
procedure pozitie(var m:longint; p,u:longint);
var i,j,di,dj,aux1:longint;
begin
di:=0;
dj:=-1;
i:=p;
j:=u;
while i<j do
begin
if s[i]>s[j] then
begin
aux1:=di;
di:=-dj;
dj:=-aux1;
aux2:=s[i];
s[i]:=s[j];
s[j]:=aux2;
end;
i:=i+di;
j:=j+dj;
end;
m:=i;
end;
procedure quick(p,u:longint);
var m:longint;
begin
if p<u then
begin
pozitie(m,p,u);
quick(p,m-1);
quick(m+1,u);
end;
end;
begin
assign(f1,'restante.in');
reset(f1);
assign(f2,'restante.out');
rewrite(f2);
readln(f1,n);
for i:=1 to n do
begin
readln(f1,s[i]);
m:=length(s[i]);
for j:=1 to m do
inc(c[ord(s[i,j])-96]);
s[i]:='';
el:=0;
for j:=1 to 26 do
while c[j]>0 do
begin
dec(c[j]);
inc(el);
s[i]:=s[i]+chr(j+96);
end;
end;
dimh:=n;
h:=n;
quick(1,n);
s[0]:='';
s[n+1]:='';
for i:=1 to n do
if (s[i]<>s[i+1])and(s[i]<>s[i-1]) then
inc(nr);
writeln(f2,nr);
close(f1);
close(f2);
end.