数据范围
对于100%的数据, 1≤n≤3×103, 1≤m≤6×103, 1≤u,v≤n, −3×105≤w≤3×105。
题目中说1≤m≤6×103,我在代码中M设为6e3 + 10, 在测试中数据8、9、11一直出现误判负环的情况,我把M改成M = 6e4 + 10就通过了全部数据了
const int N = 3e3 + 10, M = 6e3 + 10;
int n, m;
int e[M], w[M], ne[M], h[N], idx;
LL d[N][N], dh[N];
bool st[N];
int cnt[N];
void add(int a, int b, int c)
{
e[idx] = b, w[idx] = c, ne[idx] = h[a], h[a] = idx ++;
}