Cod sursa(job #1442855)
Utilizator | Data | 26 mai 2015 14:42:02 | |
---|---|---|---|
Problema | Triplete | Scor | 50 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.76 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("triplete.in");
ofstream fout("triplete.out");
const int NMax = 4100;
bool v[NMax][NMax];
int main()
{
int n, m, x, y, ans;
fin >> n >> m;
for(int i = 1; i <= m; i++){
fin >> x >> y;
v[x][y] = 1;
v[y][x] = 1;
}
ans = 0;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
if(v[i][j]){
for(int k = j + 1; k <= n; k++){
if(v[i][k] && v[k][j]){
v[j][i] = 0;
v[k][i] = 0;
ans++;
}
}
}
}
}
fout << ans;
return 0;
}