Cod sursa(job #805030)

Utilizator robertpoeRobert Poenaru robertpoe Data 30 octombrie 2012 20:33:22
Problema Triplete Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.47 kb
#include<fstream>
#include<bitset>
#define maxn 4099
#define maxm 68000
using namespace std;
ifstream f("triplete.in");
ofstream g("triplete.out");
unsigned int rez;
bitset<maxn> a[maxn];
int i,j,n,x,y,m,q[maxm][2];
int main()
{
    f>>n>>m;
    for(i=0;i<m;++i)
    {
        f>>x>>y;
        a[min(x,y)-1][max(x,y)+1]=1;
        q[i][0]=x-1;
        q[i][1]=y-1;
    }
    for(i=0;i<m;++i)
        rez+=(a[q[i][0]]&a[q[i][1]]).count();
    g<<rez<<"\n";
}