Pagini recente » Cod sursa (job #1249454) | Cod sursa (job #1414155) | Cod sursa (job #903059) | Cod sursa (job #354686) | Cod sursa (job #1192377)
#include <fstream>
#include <bitset>
#include <vector>
using namespace std;
pair <int,int> H[4096];
bitset<4096>viz[4096];
ifstream fin("triplete.in");
ofstream fout("triplete.out");
int main()
{
int n,m,i,x,y,sol=0,k=0;
fin>>n>>m;
bitset<4096>v[n+1];
bitset<4096>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;
}
}
for(i=1;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;
}