Cod sursa(job #1594894)

Utilizator AeroHHorea Stefan AeroH Data 9 februarie 2016 19:58:29
Problema Triplete Scor 90
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.62 kb
///!!! Prefetch Test !!!
#include <fstream>
using namespace std;

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

int N,M,i,j,r;
unsigned int a[4100][150];//b[4100][150];
unsigned int x[67000],y[67000],c[4100];
int main()
{
    f>>N>>M;
    for(i=1;i<=4096;++i)
        c[i]=1<<(i&31);
    while(M--)
    {
        f>>x[M]>>y[M];if(x[M]>y[M])x[M]^=y[M]^=x[M]^=y[M];
        a[x[M]][y[M]>>5]|=c[y[M]];
        //b[y[M]][x[M]>>5]|=(1<<(x[M]&31));
    }
    for(i=0;x[i];++i)
            for(j=0;(j<<5)<=N;++j)
                    r+=__builtin_popcount(a[x[i]][j]&a[y[i]][j]);
    g<<r;

    return 0;
}