Cod sursa(job #125301)

Utilizator TudorutzuMusoiu Tudor Tudorutzu Data 20 ianuarie 2008 12:27:14
Problema Restante Scor 50
Compilator fpc Status done
Runda preONI 2008, Runda 3, Clasa a 9-a Marime 0.85 kb
var a:array[1..36000] of string[16];
    n,i,j,nr:longint;
    ok:boolean;
    f,g:text;
    aux:char;
begin
     assign(f,'restante.in'); reset(f);
     assign(g,'restante.out'); rewrite(g);
     readln(f,n);
     for i:=1 to n do
     begin
          readln(f,a[i]);  j:=1;
          while j<length(a[i]) do
          begin
               if a[i][j]>a[i][j+1] then
               begin
                    aux:=a[i][j];
                    a[i][j]:=a[i][j+1];
                    a[i][j+1]:=aux;
                    if j<>1 then j:=j-2;
               end;
               inc(j);
          end;
     end;
     for i:=1 to n do
     begin
          ok:=true;
          for j:=1 to n do
               if j<>i then
               if a[j]=a[i] then ok:=false;
          if ok then inc(nr);
     end;
     writeln(g,nr);
     close(g);
end.