Cod sursa(job #2301436)

Utilizator mihailescu_eduardMihailescu Eduard-Florin mihailescu_eduard Data 12 decembrie 2018 23:00:34
Problema Triplete Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.67 kb
#include <fstream>
#include <vector>
#include <string.h>
using namespace std;

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

int n, m;
vector<int> rel[4100];
bool v[4100][4100];


int main()
{
    fin >> n >> m;
    int x, y;
    for(int i = 1; i<=m ; ++i)
    {
        fin >> x >> y;
        rel[x].push_back(y);
        rel[y].push_back(x);
        v[x][y] = v[y][x] = true;
    }
    int ct =0;

    for(int i = 1; i<= n - 2; ++i)
    {
        for(auto j : rel[i])
        {
            for(auto t : rel[j])
            {
                if(i < j && j < t)
                    if(v[i][t])
                        ct++;
            }
        }

    }
    fout << ct;
}