Cod sursa(job #2829080)
Utilizator | Andrei Chertes andrei_C1 | Data | 8 ianuarie 2022 11:41:31 |
---|---|---|---|
Problema | Triplete | Scor | 90 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.5 kb |
#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<short int, short int>> v;
bitset<NMAX> mat[NMAX];
int main() {
fin >> N >> M;
for(int i = 0; i < M; i++) {
unsigned short 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;
}