Cod sursa(job #1759482)

Utilizator BlackNestaAndrei Manaila BlackNesta Data 19 septembrie 2016 12:06:47
Problema Triplete Scor 90
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.73 kb
#include <bits/stdc++.h>
#define Nmax 4100

using namespace std;

bitset <Nmax> L[Nmax];
int n, m;

struct pereche
{
    int x, y;
};

pereche a[66000];

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

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

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