Cod sursa(job #1594757)

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

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

int N,M,i,j,r;
char a[4100][600],b[4100][600];
int x[4100],y[4100];
int main()
{
    f>>N>>M;
    while(M--)
    {
        f>>x[M]>>y[M];
        a[x[M]][y[M]>>3]|=(1<<(y[M]&7));
        b[y[M]][x[M]>>3]|=(1<<(x[M]&7));
    }
    for(i=0;x[i];++i)
        for(j=0;(j<<3)<=N;++j)
            r+=__builtin_popcount(a[x[i]][j]&b[y[i]][j]);
    g<<r;

    return 0;
}