Cod sursa(job #1851223)

Utilizator ArambasaVlad Arambasa Arambasa Data 19 ianuarie 2017 15:25:40
Problema Triplete Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.82 kb
#include <fstream>
#define Imax 4105
#define NMax 66000
using namespace std;

ifstream in ("triplete.in");
ofstream out ("triplete.out");

int Iorgu[Imax][Imax/(1<<5)], commy[NMax], sdp[NMax];
int n,m,x,y,sol;

int CountBiti (int arg)
{
	int ret=0;
	while (x)
	{
		ret++;
		x-=(x&(-x));
	}
	return ret;
} 
void Read()
{
	in>>n>>m;
	for (int i=1;i<=m;i++)
	{
		in>>commy[i]>>sdp[i];
		if (commy[i]>sdp[i])
		{
			swap(commy[i],sdp[i]);
		}
		Iorgu[commy[i]][sdp[i]/(1<<5)]+=(1<<((sdp[i]-1)%(1<<5)));
	}
}
void Solve()
{
	for (int i=1;i<=m;i++)
	{
		for (int j=0;j<=n/(1<<5);j++)
		{
			sol+=CountBiti(((Iorgu[commy[i]][j])&(Iorgu[sdp[i]][j])));
		}
	}
}
void Print()
{
//WOW
//MUCH FUNCTION
	out<<sol;
//SUCH PROGRAMMING. WOW
}
int main()
{
	Read();
	Solve();
	Print();
	return 0;
}