Pagini recente » Cod sursa (job #361384) | Cod sursa (job #2001232) | Cod sursa (job #791520) | Cod sursa (job #2826181) | Cod sursa (job #1217546)
#include <fstream>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
ifstream fi("triplete.in");
ofstream fo("triplete.out");
#define nmax 4100
typedef struct node{int x;node *next;} *nod;
nod S[nmax];
int main(void)
{
int n,m;
for (fi>>n>>m;m--;)
{
int x,y;
fi>>x>>y;
if (x>y) swap(x,y);
nod p;
p=new node;
p->x=y;p->next=S[x];S[x]=p;
}
unsigned int R=0;
for (int i=1;i<=n;++i)
for (nod j=S[i];j;j=j->next)
for (nod a=j->next;a;a=a->next)
{
int x=j->x,y=a->x;
if (x>y) swap(x,y);
for (nod p=S[x];p;p=p->next)
if (p->x==y) {++R;break;}
}
fo<<R<<"\n";
return 0;
}