Pagini recente » Cod sursa (job #868460) | Cod sursa (job #716084) | Cod sursa (job #2980569) | Cod sursa (job #2495215) | Cod sursa (job #1192384)
#include <fstream>
#include <bitset>
#include <vector>
using namespace std;
pair <int,int> H[65696];
bitset<4097>viz[4097];
ifstream fin("triplete.in");
ofstream fout("triplete.out");
int main()
{
int n,m,i,x,y,sol=0,k=0;
fin>>n>>m;
bitset<4097>v[n+1];
bitset<4097>p;
for(i=1;i<=m;i++)
{
fin>>x>>y;
v[x][y]=1;
v[y][x]=1;
if(!viz[x][y])
{
H[k++]=make_pair(x,y);
viz[x][y]=viz[y][x]=1;
}
}
k--;
for(i=0;i<=k;i++)
{ p=v[H[i].first]&v[H[i].second];
sol=sol+p.count();
v[H[i].first][H[i].second]=v[H[i].second][H[i].first]=0;
}
fout<<sol;
}