Pagini recente » Cod sursa (job #2069154) | Cod sursa (job #69239) | Cod sursa (job #2866052) | Cod sursa (job #1309631) | Cod sursa (job #1785768)
#include<bits/stdc++.h>
#define dim 10005
using namespace std;
int f(bitset<4100> a,bitset<4100> b)
{
a=(a&b);
return a.count();
}
bitset<4100> bs[4100];
int n,m,x,y,sol;
char buff[dim+5];
int poz=0;
void citeste(int &numar)
{
numar=0;
while(buff[poz]<'0' || buff[poz]>'9')
{
poz++;
if(poz==dim)
{
poz=0;
fread(buff,1,dim,stdin);
}
}
while(buff[poz]>='0' && buff[poz]<='9')
{
numar=numar*10+buff[poz]-'0';
poz++;
if(poz==dim)
{
poz=0;
fread(buff,1,dim,stdin);
}
}
}
int main()
{
freopen("triplete.in","r",stdin);
freopen("triplete.out","w",stdout);
fread(buff,1,dim,stdin);
citeste(n);
citeste(m);
for(int i=1;i<=m;i++)
{
citeste(x);
citeste(y);
bs[x][y]=1;
bs[y][x]=1;
}
for(int i=1;i<=n;i++)
{
if(bs[i].any())
{
for(int j=(i+1);j<=n;j++)
{
if(bs[i][j])
{
sol+=f(bs[i],bs[j]);
}
}
}
}
printf("%d\n",sol/3);
return 0;
}