Cod sursa(job #1759481)

Utilizator SaitamaSaitama-san Saitama Data 19 septembrie 2016 12:06:15
Problema Triplete Scor 90
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.75 kb
#include <bits/stdc++.h>
#define Nmax 4100

using namespace std;

ifstream fin("triplete.in");
ofstream fout("triplete.out");

bitset <Nmax> L[Nmax];
struct pereche
{
    short x, y;
};
pereche a[66000];
int n, m;

void Citire()
{
    int i, x, y;
    fin >> n >> m;
    for(i = 1; i <= m; i++)
    {
        fin >> x >> y;
        if(x > y) swap(x, y);
        L[x][y] = 1;
        a[i].x = x;
        a[i].y = y;
    }
    fin.close();
}

void Rezolva()
{
    int i, sol, y, x;
    sol = 0;
    for(i = 1; i <= m; i++)
    {
        x = a[i].x;
        y = a[i].y;
        sol += (L[x] & L[y]).count();
    }
    fout << sol << "\n";
    fout.close();
}

int main()
{
    Citire();
    Rezolva();
    return 0;
}