Cod sursa(job #2294045)

Utilizator Mihai145Oprea Mihai Adrian Mihai145 Data 1 decembrie 2018 20:47:34
Problema Triplete Scor 70
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.68 kb
#include <fstream>
#include <vector>

using namespace std;

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

int N, M, ans;
vector <int> a[5000];
bool d[5000][5000];

int main()
{
    fin >> N >> M;

    int x, y;
    for(int i = 1; i <= M; i++)
    {
        fin >> x >> y;

        a[x].push_back(y);
        a[y].push_back(x);
        d[x][y] = d[y][x] = true;
    }

    for(int i = 1; i <= N - 2; i++)
        for(auto it : a[i])
            for(auto it2 : a[it])
            {
                if(i < it && it < it2)
                    if(d[i][it2] == true)
                        ans++;
            }

    fout << ans;

    return 0;
}