Cod sursa(job #757295)

Utilizator vendettaSalajan Razvan vendetta Data 11 iunie 2012 19:27:49
Problema Triplete Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.74 kb
#include <fstream>
#include <iostream>

using namespace std;

#define nmax 4099

ifstream f("triplete.in");
ofstream g("triplete.out");

int n, m, a[nmax][nmax];

void citeste(){

    f >> n >> m;
    for(int i=1; i<=n; i++){
        int x, y;
        f >> x >> y;
        a[x][y] = 1;
        a[y][x] = 1;
    }

}

void rezolva(){

    int cnt = 0;

    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            for(int k=1; k<=n; k++){
                if (a[i][k] == 1 && a[k][j] == 1 && a[i][j] == 1)  ++cnt;
            }
        }
    }

    cout << cnt/3 << "\n";
    g << cnt/3 << "\n";

}

int main(){

    citeste();
    rezolva();

    f.close();
    g.close();

    return 0;

}