Pagini recente » Cod sursa (job #1672504) | Cod sursa (job #13684) | Cod sursa (job #3181207) | Cod sursa (job #2946619) | Cod sursa (job #2274088)
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
int n, m;
bool a[4100][4100];
vector<int> g[4100];
int main() {
freopen("triplete.in", "r", stdin);
freopen("triplete.out", "w", stdout);
scanf("%d %d", &n, &m);
for (int i = 0; i < m; ++i) {
int x, y;
scanf("%d %d", &x, &y);
a[x][y]++;
a[y][x]++;
if (x < y) {
g[x].push_back(y);
}
else {
g[y].push_back(x);
}
}
int result = 0;
for (int i = 1; i <= n; ++i) {
for (auto j : g[i]) {
for (int k = j + 1; k <= n; ++k) {
if (a[i][k] && a[j][k]) {
result++;
}
}
}
}
printf("%d", result);
return 0;
}