Pagini recente » Cod sursa (job #2323008) | Cod sursa (job #2722844) | Cod sursa (job #2228123) | Cod sursa (job #803857) | Cod sursa (job #300036)
Cod sursa(job #300036)
type rest=record
str:string;
x:0..1;
end;
st=string;
vector=array[0..36001] of rest;
var v:vector;
f,g:text;
i,nr,con,n,j:longint;
procedure QuickSort(var A: st; Lo, Hi: longint);
procedure Sort(l, r: longint);
var
i, j: integer;
x,y:char;
begin
i := l; j := r; x := a[(l+r) DIV 2];
repeat
while a[i] < x do i := i + 1;
while x < a[j] do j := j - 1;
if i <= j then
begin
y := a[i]; a[i] := a[j]; a[j] := y;
i := i + 1; j := j - 1;
end;
until i > j;
if l < j then Sort(l, j);
if i < r then Sort(i, r);
end;
begin {QuickSort};
Sort(Lo,Hi);
end;
procedure QuickSort2(var a:vector; Lo, Hi: longint);
procedure Sort2(l, r: longint);
var
i, j: integer;
x,y:string;
begin
i := l; j := r; x := a[(l+r) DIV 2].str;
repeat
while a[i].str < x do i := i + 1;
while x < a[j].str do j := j - 1;
if i <= j then
begin
y := a[i].str; a[i].str := a[j].str; a[j].str := y;
i := i + 1; j := j - 1;
end;
until i > j;
if l < j then Sort2(l, j);
if i < r then Sort2(i, r);
end;
begin {QuickSort};
Sort2(Lo,Hi);
end;
procedure elim(i:longint);
var j:longint;
begin
nr:=0;
for j:=1 to i-1 do if v[j].str=v[i].str then begin nr:=1; v[i].x:=1;
if v[j].x=0 then begin v[j].x:=1; inc(nr) end; break; end;
end;
begin
assign(f,'restante.in'); reset(f);
assign(g,'restante.out'); rewrite(g);
readln(f,n);
con:=n;
for i:=1 to n do begin
read(f,v[i].str);
readln(f);
quicksort(v[i].str,1,length(v[i].str));
{elim(i);}
end;
quicksort2(v,1,n);
con:=0;
i:=1;
while i<=n do
if v[i].str<>v[i+1].str then begin inc(con); inc(i); end
else begin
j:=i+1;
while (v[i].str=v[j].str) and (j<=n) do inc(j);
i:=j;
end;
write(g,con);
close(g);
end.