Pagini recente » Cod sursa (job #207332) | Cod sursa (job #2473839) | Cod sursa (job #1412570) | Cod sursa (job #715399) | Cod sursa (job #1217550)
#include <fstream>
#include <iostream>
#include <algorithm>
#include <string>
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];
char C[105];
int main(void)
{
unsigned int n,m;
for (fi>>n>>m;m--;)
{
int x=0,y=0;
fi>>C;
int A=0;
while ('0'<=C[A] && C[A]<='9') x*=10,x+=C[A]-'0',++A;
fi>>C;A=0;
while ('0'<=C[A] && C[A]<='9') y*=10,y+=C[A]-'0',++A;
if (x>y) swap(x,y);
nod p;
p=new node;
p->x=y;p->next=S[x];S[x]=p;
}
unsigned long long 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;
}