@@ -35,12 +35,12 @@ public int addEdge(int from, int to, long cap, long cost)
3535
3636``` java
3737// (1)
38- public long [] minCostMaxFlow(int s, int t)
38+ public MinCostFlow . FlowAndCost minCostMaxFlow(int s, int t)
3939// (2)
40- public long [] minCostFlow(int s, int t, long flowLimit)
40+ public MinCostFlow . FlowAndCost minCostFlow(int s, int t, long flowLimit)
4141```
4242
43- ` s ` から ` t ` へ流せるだけ流し、その流量とコストを返す。返り値は長さ 2 の配列で表現され、中身は ` { flow, cost} ` である。
43+ ` s ` から ` t ` へ流せるだけ流し、その流量とコストを返す。返り値は ` MinCostFlow.FlowAndCost ` であり,メンバに ` long flow` と ` long cost` を持つ.
4444
4545- (1): ` s ` から ` t ` へ流せるだけ流す
4646- (2): ` s ` から ` t ` へ流量 ` flowLimit ` まで流せるだけ流す
@@ -57,9 +57,9 @@ public long[] minCostFlow(int s, int t, long flowLimit)
5757
5858``` java
5959// (1)
60- public java.util.ArrayList<long[] > minCostSlope(int s, int t)
60+ public java.util.ArrayList<MinCostFlow . FlowAndCost > minCostSlope(int s, int t)
6161// (2)
62- public java.util.ArrayList<long[] > minCostSlope(int s, int t, long flowLimit)
62+ public java.util.ArrayList<MinCostFlow . FlowAndCost > minCostSlope(int s, int t, long flowLimit)
6363```
6464
6565返り値に流量とコストの関係の折れ線が入る。全ての ` x ` について、流量 ` x ` の時の最小コストを ` g(x) ` とすると、` {x, g(x)} ` は返り値を折れ線として見たものに含まれる。返り値のリストは以下のような性質を満たします。
@@ -73,54 +73,42 @@ public java.util.ArrayList<long[]> minCostSlope(int s, int t, long flowLimit)
7373制約
7474
7575- ` s != t `
76- - ` minCostSlope ` や ` minCostFlow ` を合わせて複数回呼んだときの挙動は未定義 (複数回フローを流す場合は後述の ` clearFlow ` メソッドによりフローをリセットしてください)
76+ - ` minCostSlope ` や ` minCostFlow ` を合わせて複数回呼んだときの挙動は未定義
7777
7878計算量
7979
8080` F ` を流量、` m ` を追加した辺の本数として $O(F (n + m) \log n)$
8181
82- ### clearFlow
83-
84- ``` java
85- public void clearFlow()
86- ```
87-
88- 全ての辺に流れているフローを 0 にします。
89-
90- 計算量
91-
92- ` m ` を追加した辺の本数として $O(n + m)$
93-
9482### getEdge / getEdges
9583
9684` getEdge ` 、` getEdges ` の返り値には以下のメソッドを持つ ` MinCostFlow.WeightedCapEdge ` 型が用いられています。
9785
9886``` java
9987class WeightedCapEdge {
10088 // (1)
101- public int getFrom ()
89+ public final int from;
10290 // (2)
103- public int getTo ()
91+ public final int to;
10492 // (3)
105- public long getCap ()
93+ public final long cap;
10694 // (4)
107- public long getCost ()
95+ public final long flow;
10896 // (4)
109- public long getFlow ()
97+ public final long cost;
11098};
11199```
112100
113- - (1 ): 始点を返します 。計算量: $O(1 )$
114- - (2 ): 終点を返します 。計算量: $O(1 )$
115- - (3 ): 現在の容量を返します 。計算量: $O(1 )$
116- - (4 ): コストを返します 。計算量: $O(1 )$
101+ - (1): 辺の始点を返します 。計算量: $O(1)$
102+ - (2): 辺の終点を返します 。計算量: $O(1)$
103+ - (3): 辺の容量を返します 。計算量: $O(1)$
104+ - (4): 辺のコストを返します 。計算量: $O(1)$
117105- (5): 現在の流量を返しまず。計算量: $O(1)$
118106
119107``` java
120108// (1)
121- public CapEdge getEdge (int i )
109+ public WeightedCapEdge getEdge(int i)
122110// (2)
123- public java.util.ArrayList< WeightedCapEdge > getEdges ()
111+ public WeightedCapEdge [] getEdges()
124112```
125113
126114今の内部の辺の状態を返す。辺の順番は ` addEdge ` で追加された順番と同一。
@@ -132,8 +120,8 @@ public java.util.ArrayList<WeightedCapEdge> getEdges()
132120計算量
133121
134122- (1): $O(1)$
135- - (2): $O (1 )$
123+ - (2): $O(m )$
136124
137125使用例
138126
139- [AtCoder Library Practice Contest E - MinCostFlow ](https://atcoder.jp/contests/practice2/submissions/16654383 )
127+ [ AtCoder Library Practice Contest E - MinCostFlow] ( https://atcoder.jp/contests/practice2/submissions/20811599 )
0 commit comments