Pagini recente » Monitorul de evaluare | Istoria paginii utilizator/qmihai | necromancer | Profil Johny_Depp22 | Cod sursa (job #2829076)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("triplete.in");
ofstream fout("triplete.out");
const int NMAX = 4096;
int N, M, ans;
vector<pair<int, int>> v;
bitset<NMAX> mat[NMAX];
int main() {
fin >> N >> M;
for(int i = 0; i < M; i++) {
int x, y;
x--; y--;
fin >> x >> y;
v.push_back({x, y});
mat[x][y] = 1;
mat[y][x] = 1;
}
for(int i = 0; i < M; i++) {
ans += (mat[v[i].first] & mat[v[i].second]).count();
}
fout << ans / 3 << '\n';
return 0;
}