Pagini recente » Cod sursa (job #1710902) | Cod sursa (job #1701580) | Cod sursa (job #2380874) | Cod sursa (job #2240990) | Cod sursa (job #190218)
Cod sursa(job #190218)
#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;
}