Pagini recente » Cod sursa (job #1432907) | Cod sursa (job #843833) | Cod sursa (job #150404) | Cod sursa (job #1046142) | Cod sursa (job #2567760)
#include <iostream>
#include <fstream>
#include <algorithm>
#define nmax 4100
#define mmax 65550
using namespace std;
ifstream f("triplete.in");
ofstream o("triplete.out");
struct muchie{
int x,y;
} v[mmax];
int n,m,i,j,x,y,sum;
bool a[nmax][nmax];
inline bool cmp(muchie a,muchie b){
if(a.x!=b.x) return a.x<b.x;
return a.y<b.y;
}
int main()
{
f >> n >> m;
for(i=1;i<=m;++i){
f >> x >> y;
if(x>y){
int t=x;
x=y;
y=t;
}
v[i].x=x;
v[i].y=y;
a[x][y]=a[y][x]=true;
}
sort(v+1,v+1+m,cmp);
for(i=1;i<=m;++i){
for(j=i+1; j<=m && v[i].x==v[j].x; ++j){
if(a[v[i].y][v[j].y])
++sum;
}
}
o << sum << '\n';
return 0;
}