Cod sursa(job #190218)

Utilizator andrei-alphaAndrei-Bogdan Antonescu andrei-alpha Data 21 mai 2008 07:47:07
Problema Triplete Scor 50
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.65 kb
#include <stdio.h>

#define Nmax 3000
#define Mmax 40800
#define IN "triplete.in"
#define OUT "triplete.out"

struct mch{int a,b;};
mch muchie[Mmax];
int nrm,n,m;
bool a[Nmax][Nmax];

void scan()
{
	
	int x,y;
	freopen(IN, "r",stdin);
	freopen(OUT, "w",stdout);
	
	scanf("%d%d", &n,&m);
	for(int i=1;i<=m;++i)
	{	
		scanf("%d%d", &x,&y);
		muchie[++nrm].a=x;
		muchie[nrm].b=y;
		a[x][y]=1;
		a[y][x]=1;
	}
}

void solve()
{
	int rez=0;
	for(int i=1;i<=nrm;++i)
		for(int k=1;k<=n;++k)
			if(a[muchie[i].a][k] && a[muchie[i].b][k])
				++rez;
	printf("%d", rez/3);
}

int main()
{
	scan();
	solve();
	return 0;
}