Cod sursa(job #462911)

Utilizator GheorgheMihaiMihai Gheorghe GheorgheMihai Data 14 iunie 2010 10:58:23
Problema Triplete Scor 100
Compilator cpp Status done
Runda biti2 Marime 0.53 kb
#include <stdio.h>

#include <bitset>

using namespace std;

int n, m;

bitset <4100> v[4100], x;

int main ()
{
	freopen ("triplete.in", "r", stdin);
	freopen ("triplete.out", "w", stdout);
	
	scanf ("%d %d", &n, &m);
	int i, j, a, b, sol = 0;
	
	for (i = 1; i <= m; i ++)
	{
		scanf ("%d %d", &a, &b);
		v[a][b] = 1;
		v[b][a] = 1;
	}
	
	for (i = 1; i <= n; i ++)
		for (j = i + 1; j <= n; j ++)
			if (v[i][j])
			{
				x = v[i] & v[j];
				sol += x.count ();
			}
	
	printf ("%d\n", sol / 3);
	return 0;
}