Skip to content

Commit a595e8d

Browse files
committed
fix atcoder#37: Fix deduplication by tangent
1 parent 839923f commit a595e8d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

atcoder/mincostflow.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ template <class Cap, class Cost> struct mcf_graph {
143143
result.pop_back();
144144
}
145145
result.push_back({flow, cost});
146-
prev_cost = cost;
146+
prev_cost = d;
147147
}
148148
return result;
149149
}

test/unittest/mincostflow_test.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,12 @@ TEST(MaxflowTest, SelfLoop) {
7979
mcf_graph<int, int>::edge e = {0, 0, 100, 0, 123};
8080
edge_eq(e, g.get_edge(0));
8181
}
82+
83+
TEST(MincostflowTest, SameCostPaths) {
84+
mcf_graph<int, int> g(3);
85+
ASSERT_EQ(0, g.add_edge(0, 1, 1, 1));
86+
ASSERT_EQ(1, g.add_edge(1, 2, 1, 0));
87+
ASSERT_EQ(2, g.add_edge(0, 2, 2, 1));
88+
auto expected = std::vector<std::pair<int, int>>{{0, 0}, {3, 3}};
89+
ASSERT_EQ(expected, g.slope(0, 2));
90+
}

0 commit comments

Comments
 (0)