Cod sursa(job #1762782)

Utilizator stefanst77Luca Stefan Ioan stefanst77 Data 24 septembrie 2016 09:25:01
Problema Triplete Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.72 kb
#include <bits/stdc++.h>

using namespace std;
ofstream fout ("triplete.out");
int n, m;
int a[65537], b[65537];
bitset <5000> M[5000];

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

    fin.close();
}

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

int main()
{
    Citire();
    Rezolvare();
    fout.close();
    return 0;
}