From 8b0726e6304dfe9f4c63567cb6f8f778bc12b9c9 Mon Sep 17 00:00:00 2001 From: tht2005 <75089048+tht2005@users.noreply.github.com> Date: Sun, 25 Aug 2024 12:28:49 +0700 Subject: [PATCH 1/5] Update MinCostMaxFlow.h Fix a bug that occur when maxflow function is called multiple times from different source vertices. --- content/graph/MinCostMaxFlow.h | 1 + 1 file changed, 1 insertion(+) diff --git a/content/graph/MinCostMaxFlow.h b/content/graph/MinCostMaxFlow.h index 23819ceed..29f081979 100644 --- a/content/graph/MinCostMaxFlow.h +++ b/content/graph/MinCostMaxFlow.h @@ -34,6 +34,7 @@ struct MCMF { } void path(int s) { + fill(all(par), 0); fill(all(seen), 0); fill(all(dist), INF); dist[s] = 0; ll di; From 18ac9ac14e016c3b70519c69503a620ff8d3c4ad Mon Sep 17 00:00:00 2001 From: tht2005 <75089048+tht2005@users.noreply.github.com> Date: Sun, 25 Aug 2024 12:48:36 +0700 Subject: [PATCH 2/5] Update MinCostMaxFlow.h --- content/graph/MinCostMaxFlow.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/graph/MinCostMaxFlow.h b/content/graph/MinCostMaxFlow.h index 29f081979..b2bceb647 100644 --- a/content/graph/MinCostMaxFlow.h +++ b/content/graph/MinCostMaxFlow.h @@ -34,9 +34,9 @@ struct MCMF { } void path(int s) { - fill(all(par), 0); fill(all(seen), 0); fill(all(dist), INF); + rep(i, 0, sz(par)) par[i] = NULL; dist[s] = 0; ll di; __gnu_pbds::priority_queue> q; From 1517c54be718272d908f55a327988421ea9baa33 Mon Sep 17 00:00:00 2001 From: Nguyen Dinh Dang Duong Date: Mon, 16 Sep 2024 03:43:02 +0700 Subject: [PATCH 3/5] fix par[s] = null --- content/graph/MinCostMaxFlow.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/graph/MinCostMaxFlow.h b/content/graph/MinCostMaxFlow.h index b2bceb647..a867544ce 100644 --- a/content/graph/MinCostMaxFlow.h +++ b/content/graph/MinCostMaxFlow.h @@ -36,7 +36,7 @@ struct MCMF { void path(int s) { fill(all(seen), 0); fill(all(dist), INF); - rep(i, 0, sz(par)) par[i] = NULL; + par[s] = NULL; dist[s] = 0; ll di; __gnu_pbds::priority_queue> q; From 95d915e7007533133afa8fc0b86904a663f4bd18 Mon Sep 17 00:00:00 2001 From: Nguyen Dinh Dang Duong Date: Mon, 16 Sep 2024 04:03:02 +0700 Subject: [PATCH 4/5] add multiple maxflow call with different (S, T) tests for mcmf --- stress-tests/graph/MinCostMaxFlow.cpp | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/stress-tests/graph/MinCostMaxFlow.cpp b/stress-tests/graph/MinCostMaxFlow.cpp index 17c96426b..d68f83c10 100644 --- a/stress-tests/graph/MinCostMaxFlow.cpp +++ b/stress-tests/graph/MinCostMaxFlow.cpp @@ -201,7 +201,42 @@ void testNeg() { cout<<"Tests passed!"< Date: Mon, 23 Sep 2024 03:07:52 +0700 Subject: [PATCH 5/5] change par[s] = NULL to par[s] = 0 --- content/graph/MinCostMaxFlow.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/graph/MinCostMaxFlow.h b/content/graph/MinCostMaxFlow.h index a867544ce..7912797df 100644 --- a/content/graph/MinCostMaxFlow.h +++ b/content/graph/MinCostMaxFlow.h @@ -36,7 +36,7 @@ struct MCMF { void path(int s) { fill(all(seen), 0); fill(all(dist), INF); - par[s] = NULL; + par[s] = 0; dist[s] = 0; ll di; __gnu_pbds::priority_queue> q;