题目链接 SPFA判断负环
我不知道为什么不要初始化。却通过了。
if(dist[j] > dist[t] + w[i]) { dist[j] = dist[t] + w[i]; cnt[j] = cnt[t] + 1; if(cnt[j] >= n) return true; if(!st[j]) { q.push(j); st[j] = true; } }
这个if不加初始化应该会出错吧??
0 个问答