Pagini recente » Cod sursa (job #2233019) | Cod sursa (job #472421) | Cod sursa (job #2808036) | Cod sursa (job #1479421) | Cod sursa (job #1314048)
#include <fstream>
#include <bitset>
#include <vector>
using namespace std;
const int kMaxN = 4100;
ifstream fin("triplete.in");
ofstream fout("triplete.out");
int N, M, sol;
bitset<kMaxN> ad[kMaxN], aux;
vector<int> G[kMaxN];
int main() {
fin >> N >> M;
while (M--) {
int x, y;
fin >> x >> y;
if (x > y)
swap(x, y);
G[x].push_back(y);
ad[x][y] = true;
}
for (int i = 1; i < N - 1; ++i)
for (int j : G[i]) {
aux = ad[i] & ad[j];
for (int k = j + 1; k <= N; ++k)
if (aux[k])
++sol;
}
fout << sol << "\n";
return 0;
}