Cod sursa(job #1762775)

Utilizator loo_k01Luca Silviu Catalin loo_k01 Data 24 septembrie 2016 09:14:33
Problema Triplete Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.69 kb
#include <bits/stdc++.h>

using namespace std;
bitset<4104>a[4104];
bitset<4104>b;
int n, m;

void Read()
{
    ifstream fin("triplete.in");
    fin >> n >> m;
    int i, x, y;

    for(i = 1; i<=m; i++)
    {
        fin >> x >> y;
        a[x][y] = 1;
        a[y][x] = 1;
    }
    fin.close();
}

void Solve()
{
    int i, j;
    int sol = 0;
    for(i = 1; i<=n-2; i++)
        for(j = i+1; j<=n-1; j++)
        {
            b = (a[i]&a[j]);
            b = ((b >> (j+0))<<(j+0));
            sol += b.count();
        }
    ofstream fout("triplete.out");
    fout << sol << "\n";
    fout.close();
}

int main()
{
    Read();
    Solve();
    return 0;
}