From 897e1ce25a75c803bbadff3b3c6108f209946b0f Mon Sep 17 00:00:00 2001 From: lthero <70460095+lthero-big@users.noreply.github.com> Date: Tue, 26 Aug 2025 23:59:04 +0800 Subject: [PATCH] =?UTF-8?q?Update=200095.=E5=9F=8E=E5=B8=82=E9=97=B4?= =?UTF-8?q?=E8=B4=A7=E7=89=A9=E8=BF=90=E8=BE=93II.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修正卡码网0095.城市间货物运输II中,Python解决SPFA方法求解含有负回路的最短路问题的错误 count[next_node] += 1应该在 if next_node not in d: 语句块内 --- ...27\264\350\264\247\347\211\251\350\277\220\350\276\223II.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/problems/kamacoder/0095.\345\237\216\345\270\202\351\227\264\350\264\247\347\211\251\350\277\220\350\276\223II.md" "b/problems/kamacoder/0095.\345\237\216\345\270\202\351\227\264\350\264\247\347\211\251\350\277\220\350\276\223II.md" index f9cf8151b0..736fd6dcee 100644 --- "a/problems/kamacoder/0095.\345\237\216\345\270\202\351\227\264\350\264\247\347\211\251\350\277\220\350\276\223II.md" +++ "b/problems/kamacoder/0095.\345\237\216\345\270\202\351\227\264\350\264\247\347\211\251\350\277\220\350\276\223II.md" @@ -509,8 +509,8 @@ def main(): for next_node, val in graph[cur_node]: if min_dist[next_node] > min_dist[cur_node] + val: min_dist[next_node] = min_dist[cur_node] + val - count[next_node] += 1 if next_node not in d: + count[next_node] += 1 d.append(next_node) if count[next_node] == n: # 如果某个点松弛了n次,说明有负回路 flag = True