Cod sursa(job #7325)

Utilizator floringh06Florin Ghesu floringh06 Data 21 ianuarie 2007 13:27:06
Problema Triplete Scor 0
Compilator fpc Status done
Runda preONI 2007, Runda 1, Clasa a 10-a Marime 1.37 kb
{$A+,B-,D+,E-,F-,G+,I+,L+,N+,O-,P-,Q-,R-,S+,T-,V+,X+,Y+}
{$M 65520,0,655360}

var fi,fo:text;
    i,j,n,m,aux,ct,vl1,vl,aux1:longint;
    p:string;
    v:array[1..5000] of integer;
    s:array[1..5000] of string;


 begin
    assign(fi,'triplete.in'); reset(fi);
    assign(fo,'triplete.out'); rewrite(fo);
    readln(fi,n,m);
    for i:=1 to m do
      begin
       readln(fi,aux,aux1);
       p:='';
       str(aux1,p);
       s[aux]:=s[aux] + p;
       p:='';
       str(aux,p);
       s[aux1]:=s[aux1] + p;
      end;
    for i:=1 to n do
     begin
       ct:=0;
       for j:=1 to length(s[i]) do
          begin
            p:='';
            if pos(s[i][j],s[j])<>0 then
              begin
               inc(ct);
              end;
            if ct=3 then
               inc(vl1);
            if ct=4 then
             begin
              vl1:=0;
              inc(vl1,4)
             end;
           if ct=5 then
             begin
              vl1:=0;
              inc(vl1,20)
             end;
            if ct=6 then
             begin
              vl1:=0;
              inc(vl1,120)
             end;
            if ct=7 then
             begin
              vl1:=0;
              inc(vl1,840)
             end;
           inc(vl,vl1);
         end;
     end;
     writeln(fo,vl-1);
   close(fi);
   close(fo);
 end.