Cod sursa(job #1594764)
| Utilizator | Data | 9 februarie 2016 18:51:48 | |
|---|---|---|---|
| Problema | Triplete | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.49 kb |
#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];
int x[67000],y[67000];
int main()
{
f>>N>>M;
while(M--)
{
f>>x[M]>>y[M];
a[x[M]][y[M]>>5]|=(1<<(y[M]&31));
b[y[M]][x[M]>>5]|=(1<<(x[M]&31));
}
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;
}
