用 bitset 写的暴力,第 7 个点 MLE,其余 AC
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int N = 2e3 + 5, M = 5e4 + 5;
short a[M], b[M], c[M];
int n, m;
bitset<N> tag[N][N];
int main()
{
ios::sync_with_stdio(false), cin.tie(0);
cin >> n >> m;
for (int i = 1; i <= m; i++)
{
cin >> a[i] >> b[i] >> c[i];
tag[a[i]][b[i]].set(c[i]);
}
int ans = 0;
for (int i = 1; i <= m; i++)
{
short x = a[i], y = b[i], z = c[i];
for (int d = z + 1; d <= n; d++)
{
if (tag[x][y].test(d) && tag[x][z].test(d) && tag[y][z].test(d)) ans++;
}
}
cout << ans;
return 0;
}