Cod sursa(job #129676)

Utilizator loriKis Levente Lorand lori Data 29 ianuarie 2008 21:04:04
Problema Restante Scor 50
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.02 kb
var n,i,j:longint;
    c:char;
    aux:string;
    v,a:array [1..36000] of string[20];
    gasit:boolean;
    v2,a2:array ['a'..'z'] of longint;
begin
 assign(input,'restante.in'); reset(input);
 assign(output,'restante.out'); rewrite(output);
  readln(n);
  for i:=1 to n do begin
   readln(v[i]);
{  repeat
    gasit:=false;
    for j:=1 to length(v[i])-1 do
     if v[i][j]>v[i][j+1] then begin
      aux:=v[i][j]; v[i][j]:=v[i][j+1]; v[i][j+1]:=aux; gasit:=true;
     end;
   until not gasit
}  for j:=1 to length(v[i]) do inc(v2[v[i][j]]);
   v[i]:=a[i];
   for c:='a' to 'z' do
    for j:=1 to v2[c] do v[i]:=v[i]+c;
   v2:=a2;
  end;
  repeat
   gasit:=false;
   for i:=1 to n-1 do
    if v[i]>v[i+1] then begin
     aux:=v[i]; v[i]:=v[i+1]; v[i+1]:=aux; gasit:=true;
    end;
  until not gasit;
  a:=v;
  for i:=1 to n-1 do begin
   if v[i]=v[i+1] then begin a[i]:='!'; a[i+1]:='!'; end;

  end; j:=0;
  for i:=1 to n do
   if a[i]<>'!' then inc(j);
  writeln(j);
 close(input); close(output);
end.