Cod sursa(job #22242)

Utilizator pocaituDavid si Goliat pocaitu Data 25 februarie 2007 23:09:52
Problema Triplete Scor 70
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.63 kb
#include<fstream.h>
int long a,b,n,k,d;
int long m,i,j,t,x;
int c,nr,l[4099][270];
int min(int x,int y)
{if(x<y)
  return x;
 return y;
 }
int main()
{int ma[65666][2];
 ifstream f("triplete.in");
 f>>n>>m;
 for(i=1;i<=m;i++)
  {f>>a>>b;
   ma[++k][0]=a;
   ma[k][1]=b;
   l[a][b/15]|=(1<<(b%15));
   l[b][a/15]|=(1<<(a%15));
   }


for(i=1;i<=k;i++)
  {x=min(ma[i][0],ma[i][1]);
  for(j=0;j<=x/15;j++)
	  {c=l[ma[i][0]][j]&l[ma[i][1]][j];
	   if(j==x/15)
		 t=x%15;
	   else
		 t=15;
	   for(d=0;d<t;d++)
		 if(c&(1<<d))
		   nr++;
	   }    }


 ofstream g("triplete.out");
g<<nr;
g.close();
return 0;
}