Cod sursa(job #1594835)

Utilizator AeroHHorea Stefan AeroH Data 9 februarie 2016 19:19:58
Problema Triplete Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.52 kb
#include <fstream>
using namespace std;

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

int N,M,i,j,r;
long long int a[4100][65],b[4100][65];
int x[67000],y[67000];
int main()
{
    f>>N>>M;
    while(M--)
    {
        f>>x[M]>>y[M];if(x[M]>y[M])swap(x[M],y[M]);
        a[x[M]][y[M]>>6]|=(1<<(y[M]&63));
        b[y[M]][x[M]>>6]|=(1<<(x[M]&63));
    }
    for(i=0;x[i];++i)
        for(j=0;(j<<6)<=N;++j)
            r+=__builtin_popcountll(a[x[i]][j]&b[y[i]][j]);
    g<<r;

    return 0;
}