Pagini recente » Cod sursa (job #1936834) | Cod sursa (job #2664428) | Cod sursa (job #1076732) | Cod sursa (job #2444447) | Cod sursa (job #1587007)
#include <fstream>
using namespace std;
#define Nmax 4100
#define Bmax 64
ifstream fin ( "triplete.in" );
ofstream fout ( "triplete.out" );
typedef unsigned long long ULL;
ULL v[Nmax][Bmax];
void Addbit ( int x, int y ){
int Bucket = Bmax - (y / 64);
int Bit = y % 64;
v[x][Bucket] |= ( 1LL << Bit );
}
int NrBits ( ULL x ){
return __builtin_popcountll (x);
}
int main(){
int N, M, x, y;
fin >> N >> M;
while ( M-- ){
fin >> x >> y;
if ( x > y )
swap ( x, y );
x--; y--;
Addbit ( x, y );
//Addbit ( y, x );
}
long long Sol = 0;
for ( int i = 0; i < N; ++i ){
int Nr = 0;
for ( int j = 0; j < Bmax; ++j )
Nr += NrBits(v[i][j]);
Sol += 1LL * Nr * (Nr-1) / 2;
}
fout << Sol;
return 0;
}