fork download
  1. // push-relabel cost-scaling by Min-25
  2. // uploaded by dacin21
  3. /* original source (url long dead, Min-25 deleted his account?):
  4.  * https://gist
  5.  * .github.com/min-25/05e2a0161b6a919d321e116dd78c7535
  6.  * (line-wrapped so ideone doesn't nuke the link.)
  7.  */
  8.  
  9. template <
  10. typename CapType, typename TotalCapType,
  11. typename CostType, typename TotalCostType
  12. >
  13. class CostScaling {
  14. private:
  15. static const int alpha = 4; // eps <- max(1, eps / alpha)
  16.  
  17. using cap_t = CapType;
  18. using tcap_t = TotalCapType;
  19. using cost_t = CostType; // > max{|C|} * (2 * |V|)
  20. using tcost_t = TotalCostType;
  21. static constexpr cost_t Inf = (tcap_t(1) << (sizeof(tcap_t) * 8 - 2)) - 1;
  22.  
  23. struct InputEdge { int from, to; cap_t b, c; cost_t cost; };
  24. struct Edge { int to, rev; cap_t cap; cost_t cost; };
  25.  
  26. class Dinic {
  27. public:
  28. Dinic(int N, const vector<int>& ofs, vector<Edge>& edges,
  29. vector<tcap_t>& capacity)
  30. : N(N), ofs(ofs), edges(edges), capacity(capacity), last(N) {}
  31.  
  32. bool succeeded() {
  33. // s -> u: capacity[u]
  34. // u -> t: capacity[u + N]
  35. tcap_t f = 0;
  36. for (int u = 0; u < N; ++u) f += capacity[u];
  37. vector<int> que(N);
  38. while (f) {
  39. dist.assign(N, -1);
  40. int qh = 0, qt = 0, lv = N;
  41. for (int u = 0; u < N; ++u) if (capacity[u] > 0) que[qt++] = u, dist[u] = 0;
  42. for (; qh < qt; ) {
  43. int u = que[qh++];
  44. if (lv == N && capacity[u + N] > 0) lv = dist[u];
  45. if (dist[u] > lv) break;
  46. for (int ei = ofs[u]; ei < ofs[u + 1]; ++ei) {
  47. int v = edges[ei].to;
  48. if (edges[ei].cap > 0 && dist[v] == -1) {
  49. que[qt++] = v, dist[v] = dist[u] + 1;
  50. }
  51. }
  52. }
  53. if (lv == N) break;
  54. for (int u = 0; u < N; ++u) last[u] = ofs[u];
  55. for (int u = 0; u < N; ++u) if (capacity[u] > 0) {
  56. auto df = block_flow(u, capacity[u]);
  57. f -= df, capacity[u] -= df;
  58. }
  59. }
  60. return f == 0;
  61. }
  62.  
  63. private:
  64. tcap_t block_flow(int u, tcap_t f) {
  65. tcap_t ret = 0;
  66. if (capacity[u + N] > 0) {
  67. tcap_t df = min(f, capacity[u + N]);
  68. capacity[u + N] -= df;
  69. return df;
  70. }
  71. for (auto& ei = last[u]; ei < ofs[u + 1]; ++ei) {
  72. auto& e = edges[ei]; int v = e.to;
  73. if (e.cap == 0 || dist[v] <= dist[u]) continue;
  74. cap_t df = block_flow(v, min<cap_t>(e.cap, f));
  75. if (df == 0) continue;
  76. e.cap -= df, edges[e.rev].cap += df;
  77. f -= df, ret += df;
  78. if (f == 0) break;
  79. }
  80. return ret;
  81. }
  82.  
  83. int N;
  84. const vector<int>& ofs;
  85. vector<Edge>& edges;
  86. vector<tcap_t>& capacity;
  87. vector<int> last, dist;
  88. };
  89.  
  90. public:
  91. CostScaling(int N, int M=0) : N(N), capacity(2 * N) {
  92. if (M > 0) in.reserve(M);
  93. }
  94.  
  95. void add_edge(int u, int v, cost_t cost, cap_t c, cap_t b = 0) {
  96. if (b > 0) capacity[v] += b, capacity[u + N] += b;
  97. else capacity[u] += -b, capacity[v + N] += -b;
  98. in.push_back({u, v, b, c, cost});
  99. }
  100.  
  101. pair<bool, tcost_t> minimum_cost_circulation() {
  102. construct();
  103. if (!has_feasible_circulation()) return {false, 0};
  104.  
  105. const int cost_multiplier = 2 << __lg(N); // should be > |V|
  106. cost_t eps = 0;
  107. for (auto& e : edges) e.cost *= cost_multiplier, eps = max(eps, e.cost);
  108.  
  109. while (eps > 1) refine(eps = max<cost_t>(1, eps / alpha));
  110.  
  111. tcost_t ret = initial_cost;
  112. for (auto& e : edges) ret -= (e.cost / cost_multiplier) * e.cap;
  113. return {true, ret / 2};
  114. }
  115.  
  116. private:
  117. void refine(const cost_t eps) {
  118. auto cost_p = [&] (int u, const Edge& e) {
  119. return e.cost + potential[u] - potential[e.to];
  120. };
  121. for (int u = 0; u < N; ++u) for (int i = ofs[u]; i < ofs[u + 1]; ++i) {
  122. auto& e = edges[i];
  123. if (cost_p(u, e) < 0) edges[e.rev].cap += e.cap, e.cap = 0;
  124. }
  125. vector<tcap_t> excess(initial_excess);
  126. for (auto& e : edges) excess[e.to] -= e.cap;
  127.  
  128. vector<int> stack; stack.reserve(N);
  129. for (int u = 0; u < N; ++u) if (excess[u] > 0) stack.push_back(u);
  130.  
  131. auto residue = [&] (const Edge& e) -> cap_t { return e.cap; };
  132. auto push = [&] (int u, Edge& e, cap_t df) {
  133. e.cap -= df; edges[e.rev].cap += df;
  134. excess[e.to] += df; excess[u] -= df;
  135. if (excess[e.to] > 0 && excess[e.to] <= df) {
  136. stack.push_back(e.to);
  137. }
  138. };
  139. auto relabel = [&] (int u, cost_t delta) {
  140. potential[u] -= delta + eps;
  141. };
  142. auto relabel_in_advance = [&] (int u) {
  143. if (excess[u] != 0) return false;
  144. auto delta = Inf;
  145. for (int ei = ofs[u]; ei < ofs[u + 1]; ++ei) {
  146. auto& e = edges[ei];
  147. if (residue(e) == 0) continue;
  148. if (cost_p(u, e) < 0) return false;
  149. else delta = min<tcost_t>(delta, cost_p(u, e));
  150. }
  151. relabel(u, delta);
  152. return true;
  153. };
  154. auto discharge = [&] (int u) {
  155. auto delta = Inf;
  156. for (int ei = ofs[u]; ei < ofs[u + 1]; ++ei) {
  157. auto& e = edges[ei];
  158. if (residue(e) == 0) continue;
  159. if (cost_p(u, e) < 0) {
  160. if (relabel_in_advance(e.to)) {
  161. --ei; continue; // modify ei (!)
  162. }
  163. cap_t df = min<tcap_t>(excess[u], residue(e));
  164. push(u, e, df);
  165. if (!excess[u]) return;
  166. } else delta = min<tcost_t>(delta, cost_p(u, e));
  167. }
  168. relabel(u, delta);
  169. stack.push_back(u);
  170. };
  171. while (!stack.empty()) {
  172. auto u = stack.back(); stack.pop_back();
  173. discharge(u);
  174. }
  175. }
  176.  
  177. void construct() {
  178. ofs.assign(N + 1, 0);
  179. edges.resize(2 * in.size());
  180. initial_excess.assign(N, 0);
  181. initial_cost = 0;
  182. potential.assign(N, 0);
  183. for (auto& e : in) ofs[e.from + 1]++, ofs[e.to + 1]++;
  184. for (int i = 1; i <= N; ++i) ofs[i] += ofs[i - 1];
  185. for (auto& e : in) {
  186. initial_excess[e.to] += e.c;
  187. initial_excess[e.from] += -e.b;
  188. initial_cost += tcost_t(e.cost) * (e.c + e.b);
  189. edges[ofs[e.from]++] = {e.to, ofs[e.to], e.c - e.b, e.cost};
  190. edges[ofs[e.to]++] = {e.from, ofs[e.from] - 1, 0, -e.cost};
  191. }
  192. for (int i = N; i > 0; --i) ofs[i] = ofs[i - 1];
  193. ofs[0] = 0;
  194. }
  195.  
  196. bool has_feasible_circulation() {
  197. return Dinic(N, ofs, edges, capacity).succeeded();
  198. }
  199.  
  200. private:
  201. int N;
  202. vector<InputEdge> in;
  203. vector<tcap_t> capacity;
  204.  
  205. vector<int> ofs;
  206. vector<Edge> edges;
  207.  
  208. tcost_t initial_cost;
  209. vector<tcap_t> initial_excess;
  210. vector<tcost_t> potential;
  211. };
  212. // cap, total_cap, cost * (2 * |V|), total_cost
  213. using MCC = CostScaling<int, int, int64_t, int64_t>;
  214.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:24:24: error: ‘vector’ does not name a type
     Dinic(int N, const vector<int>& ofs, vector<Edge>& edges,
                        ^~~~~~
prog.cpp:24:30: error: expected ‘,’ or ‘...’ before ‘<’ token
     Dinic(int N, const vector<int>& ofs, vector<Edge>& edges,
                              ^
prog.cpp:80:11: error: ‘vector’ does not name a type
     const vector<int>& ofs;
           ^~~~~~
prog.cpp:81:5: error: ‘vector’ does not name a type
     vector<Edge>& edges;
     ^~~~~~
prog.cpp:82:5: error: ‘vector’ does not name a type
     vector<tcap_t>& capacity;
     ^~~~~~
prog.cpp:83:5: error: ‘vector’ does not name a type
     vector<int> last, dist;
     ^~~~~~
prog.cpp:97:3: error: ‘pair’ does not name a type
   pair<bool, tcost_t> minimum_cost_circulation() {
   ^~~~
prog.cpp:198:3: error: ‘vector’ does not name a type
   vector<InputEdge> in;
   ^~~~~~
prog.cpp:199:3: error: ‘vector’ does not name a type
   vector<tcap_t> capacity;
   ^~~~~~
prog.cpp:201:3: error: ‘vector’ does not name a type
   vector<int> ofs;
   ^~~~~~
prog.cpp:202:3: error: ‘vector’ does not name a type
   vector<Edge> edges;
   ^~~~~~
prog.cpp:205:3: error: ‘vector’ does not name a type
   vector<tcap_t> initial_excess;
   ^~~~~~
prog.cpp:206:3: error: ‘vector’ does not name a type
   vector<tcost_t> potential;
   ^~~~~~
prog.cpp: In constructor ‘CostScaling<CapType, TotalCapType, CostType, TotalCostType>::Dinic::Dinic(int, int)’:
prog.cpp:26:15: error: class ‘CostScaling<CapType, TotalCapType, CostType, TotalCostType>::Dinic’ does not have any field named ‘ofs’
       : N(N), ofs(ofs), edges(edges), capacity(capacity), last(N) {}
               ^~~
prog.cpp:26:19: error: ‘ofs’ was not declared in this scope
       : N(N), ofs(ofs), edges(edges), capacity(capacity), last(N) {}
                   ^~~
prog.cpp:26:25: error: class ‘CostScaling<CapType, TotalCapType, CostType, TotalCostType>::Dinic’ does not have any field named ‘edges’
       : N(N), ofs(ofs), edges(edges), capacity(capacity), last(N) {}
                         ^~~~~
prog.cpp:26:31: error: ‘edges’ was not declared in this scope
       : N(N), ofs(ofs), edges(edges), capacity(capacity), last(N) {}
                               ^~~~~
prog.cpp:26:31: note: suggested alternative: ‘Edge’
       : N(N), ofs(ofs), edges(edges), capacity(capacity), last(N) {}
                               ^~~~~
                               Edge
prog.cpp:26:39: error: class ‘CostScaling<CapType, TotalCapType, CostType, TotalCostType>::Dinic’ does not have any field named ‘capacity’
       : N(N), ofs(ofs), edges(edges), capacity(capacity), last(N) {}
                                       ^~~~~~~~
prog.cpp:26:48: error: ‘capacity’ was not declared in this scope
       : N(N), ofs(ofs), edges(edges), capacity(capacity), last(N) {}
                                                ^~~~~~~~
prog.cpp:26:48: note: suggested alternative: ‘cap_t’
       : N(N), ofs(ofs), edges(edges), capacity(capacity), last(N) {}
                                                ^~~~~~~~
                                                cap_t
prog.cpp:26:59: error: class ‘CostScaling<CapType, TotalCapType, CostType, TotalCostType>::Dinic’ does not have any field named ‘last’
       : N(N), ofs(ofs), edges(edges), capacity(capacity), last(N) {}
                                                           ^~~~
prog.cpp: In member function ‘bool CostScaling<CapType, TotalCapType, CostType, TotalCostType>::Dinic::succeeded()’:
prog.cpp:32:40: error: ‘capacity’ was not declared in this scope
       for (int u = 0; u < N; ++u) f += capacity[u];
                                        ^~~~~~~~
prog.cpp:32:40: note: suggested alternative: ‘cap_t’
       for (int u = 0; u < N; ++u) f += capacity[u];
                                        ^~~~~~~~
                                        cap_t
prog.cpp:33:7: error: ‘vector’ was not declared in this scope
       vector<int> que(N);
       ^~~~~~
prog.cpp:33:14: error: expected primary-expression before ‘int’
       vector<int> que(N);
              ^~~
prog.cpp:35:9: error: ‘dist’ was not declared in this scope
         dist.assign(N, -1);
         ^~~~
prog.cpp:35:9: note: suggested alternative: ‘int’
         dist.assign(N, -1);
         ^~~~
         int
prog.cpp:37:41: error: ‘capacity’ was not declared in this scope
         for (int u = 0; u < N; ++u) if (capacity[u] > 0) que[qt++] = u, dist[u] = 0;
                                         ^~~~~~~~
prog.cpp:37:41: note: suggested alternative: ‘cap_t’
         for (int u = 0; u < N; ++u) if (capacity[u] > 0) que[qt++] = u, dist[u] = 0;
                                         ^~~~~~~~
                                         cap_t
prog.cpp:37:58: error: ‘que’ was not declared in this scope
         for (int u = 0; u < N; ++u) if (capacity[u] > 0) que[qt++] = u, dist[u] = 0;
                                                          ^~~
prog.cpp:39:19: error: ‘que’ was not declared in this scope
           int u = que[qh++];
                   ^~~
prog.cpp:40:26: error: ‘capacity’ was not declared in this scope
           if (lv == N && capacity[u + N] > 0) lv = dist[u];
                          ^~~~~~~~
prog.cpp:40:26: note: suggested alternative: ‘cap_t’
           if (lv == N && capacity[u + N] > 0) lv = dist[u];
                          ^~~~~~~~
                          cap_t
prog.cpp:42:25: error: ‘ofs’ was not declared in this scope
           for (int ei = ofs[u]; ei < ofs[u + 1]; ++ei) {
                         ^~~
prog.cpp:43:21: error: ‘edges’ was not declared in this scope
             int v = edges[ei].to;
                     ^~~~~
prog.cpp:43:21: note: suggested alternative: ‘Edge’
             int v = edges[ei].to;
                     ^~~~~
                     Edge
prog.cpp:50:37: error: ‘last’ was not declared in this scope
         for (int u = 0; u < N; ++u) last[u] = ofs[u];
                                     ^~~~
prog.cpp:50:37: note: suggested alternative: ‘class’
         for (int u = 0; u < N; ++u) last[u] = ofs[u];
                                     ^~~~
                                     class
prog.cpp:50:47: error: ‘ofs’ was not declared in this scope
         for (int u = 0; u < N; ++u) last[u] = ofs[u];
                                               ^~~
prog.cpp:51:41: error: ‘capacity’ was not declared in this scope
         for (int u = 0; u < N; ++u) if (capacity[u] > 0) {
                                         ^~~~~~~~
prog.cpp:51:41: note: suggested alternative: ‘cap_t’
         for (int u = 0; u < N; ++u) if (capacity[u] > 0) {
                                         ^~~~~~~~
                                         cap_t
prog.cpp: In member function ‘CostScaling<CapType, TotalCapType, CostType, TotalCostType>::tcap_t CostScaling<CapType, TotalCapType, CostType, TotalCostType>::Dinic::block_flow(int, CostScaling<CapType, TotalCapType, CostType, TotalCostType>::tcap_t)’:
prog.cpp:62:11: error: ‘capacity’ was not declared in this scope
       if (capacity[u + N] > 0) {
           ^~~~~~~~
prog.cpp:62:11: note: suggested alternative: ‘cap_t’
       if (capacity[u + N] > 0) {
           ^~~~~~~~
           cap_t
prog.cpp:67:23: error: ‘last’ was not declared in this scope
       for (auto& ei = last[u]; ei < ofs[u + 1]; ++ei) {
                       ^~~~
prog.cpp:67:23: note: suggested alternative: ‘class’
       for (auto& ei = last[u]; ei < ofs[u + 1]; ++ei) {
                       ^~~~
                       class
prog.cpp:67:37: error: ‘ofs’ was not declared in this scope
       for (auto& ei = last[u]; ei < ofs[u + 1]; ++ei) {
                                     ^~~
prog.cpp:68:19: error: ‘edges’ was not declared in this scope
         auto& e = edges[ei]; int v = e.to;
                   ^~~~~
prog.cpp:68:19: note: suggested alternative: ‘Edge’
         auto& e = edges[ei]; int v = e.to;
                   ^~~~~
                   Edge
prog.cpp:69:27: error: ‘dist’ was not declared in this scope
         if (e.cap == 0 || dist[v] <= dist[u]) continue;
                           ^~~~
prog.cpp:69:27: note: suggested alternative: ‘int’
         if (e.cap == 0 || dist[v] <= dist[u]) continue;
                           ^~~~
                           int
prog.cpp:70:34: error: ‘min’ was not declared in this scope
         cap_t df = block_flow(v, min<cap_t>(e.cap, f));
                                  ^~~
prog.cpp:70:43: error: expected primary-expression before ‘>’ token
         cap_t df = block_flow(v, min<cap_t>(e.cap, f));
                                           ^
prog.cpp: In constructor ‘CostScaling<CapType, TotalCapType, CostType, TotalCostType>::CostScaling(int, int)’:
prog.cpp:87:39: error: class ‘CostScaling<CapType, TotalCapType, CostType, TotalCostType>’ does not have any field named ‘capacity’
   CostScaling(int N, int M=0) : N(N), capacity(2 * N) {
                                       ^~~~~~~~
prog.cpp:88:16: error: ‘in’ was not declared in this scope
     if (M > 0) in.reserve(M);
                ^~
prog.cpp:88:16: note: suggested alternative: ‘int’
     if (M > 0) in.reserve(M);
                ^~
                int
prog.cpp: In member function ‘void CostScaling<CapType, TotalCapType, CostType, TotalCostType>::add_edge(int, int, CostScaling<CapType, TotalCapType, CostType, TotalCostType>::cost_t, CostScaling<CapType, TotalCapType, CostType, TotalCostType>::cap_t, CostScaling<CapType, TotalCapType, CostType, TotalCostType>::cap_t)’:
prog.cpp:92:16: error: ‘capacity’ was not declared in this scope
     if (b > 0) capacity[v] += b, capacity[u + N] += b;
                ^~~~~~~~
prog.cpp:92:16: note: suggested alternative: ‘cap_t’
     if (b > 0) capacity[v] += b, capacity[u + N] += b;
                ^~~~~~~~
                cap_t
prog.cpp:93:10: error: ‘capacity’ was not declared in this scope
     else capacity[u] += -b, capacity[v + N] += -b;
          ^~~~~~~~
prog.cpp:93:10: note: suggested alternative: ‘cap_t’
     else capacity[u] += -b, capacity[v + N] += -b;
          ^~~~~~~~
          cap_t
prog.cpp:94:5: error: ‘in’ was not declared in this scope
     in.push_back({u, v, b, c, cost});
     ^~
prog.cpp:94:5: note: suggested alternative: ‘int’
     in.push_back({u, v, b, c, cost});
     ^~
     int
prog.cpp: In lambda function:
prog.cpp:115:23: error: ‘potential’ was not declared in this scope
       return e.cost + potential[u] - potential[e.to];
                       ^~~~~~~~~
prog.cpp: In member function ‘void CostScaling<CapType, TotalCapType, CostType, TotalCostType>::refine(CostScaling<CapType, TotalCapType, CostType, TotalCostType>::cost_t)’:
prog.cpp:117:46: error: ‘ofs’ was not declared in this scope
     for (int u = 0; u < N; ++u) for (int i = ofs[u]; i < ofs[u + 1]; ++i) {
                                              ^~~
prog.cpp:118:17: error: ‘edges’ was not declared in this scope
       auto& e = edges[i];
                 ^~~~~
prog.cpp:118:17: note: suggested alternative: ‘Edge’
       auto& e = edges[i];
                 ^~~~~
                 Edge
prog.cpp:121:5: error: ‘vector’ was not declared in this scope
     vector<tcap_t> excess(initial_excess);
     ^~~~~~
prog.cpp:121:18: error: expected primary-expression before ‘>’ token
     vector<tcap_t> excess(initial_excess);
                  ^
prog.cpp:121:27: error: ‘initial_excess’ was not declared in this scope
     vector<tcap_t> excess(initial_excess);
                           ^~~~~~~~~~~~~~
prog.cpp:121:27: note: suggested alternative: ‘initial_cost’
     vector<tcap_t> excess(initial_excess);
                           ^~~~~~~~~~~~~~
                           initial_cost
prog.cpp:121:20: error: there are no arguments to ‘excess’ that depend on a template parameter, so a declaration of ‘excess’ must be available [-fpermissive]
     vector<tcap_t> excess(initial_excess);
                    ^~~~~~
prog.cpp:121:20: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
prog.cpp:122:20: error: ‘edges’ was not declared in this scope
     for (auto& e : edges) excess[e.to] -= e.cap;
                    ^~~~~
prog.cpp:122:20: note: suggested alternative: ‘Edge’
     for (auto& e : edges) excess[e.to] -= e.cap;
                    ^~~~~
                    Edge
prog.cpp:122:27: error: ‘excess’ was not declared in this scope
     for (auto& e : edges) excess[e.to] -= e.cap;
                           ^~~~~~
prog.cpp:122:27: note: suggested alternative: ‘extern’
     for (auto& e : edges) excess[e.to] -= e.cap;
                           ^~~~~~
                           extern
prog.cpp:124:12: error: expected primary-expression before ‘int’
     vector<int> stack; stack.reserve(N);
            ^~~
prog.cpp:124:24: error: ‘stack’ was not declared in this scope
     vector<int> stack; stack.reserve(N);
                        ^~~~~
prog.cpp:125:37: error: ‘excess’ was not declared in this scope
     for (int u = 0; u < N; ++u) if (excess[u] > 0) stack.push_back(u);
                                     ^~~~~~
prog.cpp:125:37: note: suggested alternative: ‘extern’
     for (int u = 0; u < N; ++u) if (excess[u] > 0) stack.push_back(u);
                                     ^~~~~~
                                     extern
prog.cpp: In lambda function:
prog.cpp:129:20: error: ‘edges’ was not declared in this scope
       e.cap -= df; edges[e.rev].cap += df;
                    ^~~~~
prog.cpp:129:20: note: suggested alternative: ‘Edge’
       e.cap -= df; edges[e.rev].cap += df;
                    ^~~~~
                    Edge
prog.cpp:130:7: error: ‘excess’ was not declared in this scope
       excess[e.to] += df; excess[u] -= df;
       ^~~~~~
prog.cpp:130:7: note: suggested alternative: ‘extern’
       excess[e.to] += df; excess[u] -= df;
       ^~~~~~
       extern
prog.cpp: In lambda function:
prog.cpp:136:7: error: ‘potential’ was not declared in this scope
       potential[u] -= delta + eps;
       ^~~~~~~~~
prog.cpp: In lambda function:
prog.cpp:139:8: error: ‘excess’ was not declared in this scope
    if (excess[u] != 0) return false;
        ^~~~~~
prog.cpp:139:8: note: suggested alternative: ‘extern’
    if (excess[u] != 0) return false;
        ^~~~~~
        extern
prog.cpp:141:21: error: ‘ofs’ was not declared in this scope
       for (int ei = ofs[u]; ei < ofs[u + 1]; ++ei) {
                     ^~~
prog.cpp:142:19: error: ‘edges’ was not declared in this scope
         auto& e = edges[ei];
                   ^~~~~
prog.cpp:142:19: note: suggested alternative: ‘Edge’
         auto& e = edges[ei];
                   ^~~~~
                   Edge
prog.cpp:145:22: error: ‘min’ was not declared in this scope
         else delta = min<tcost_t>(delta, cost_p(u, e));
                      ^~~
prog.cpp:145:33: error: expected primary-expression before ‘>’ token
         else delta = min<tcost_t>(delta, cost_p(u, e));
                                 ^
prog.cpp: In lambda function:
prog.cpp:152:21: error: ‘ofs’ was not declared in this scope
       for (int ei = ofs[u]; ei < ofs[u + 1]; ++ei) {
                     ^~~
prog.cpp:153:19: error: ‘edges’ was not declared in this scope
         auto& e = edges[ei];
                   ^~~~~
prog.cpp:153:19: note: suggested alternative: ‘Edge’
         auto& e = edges[ei];
                   ^~~~~
                   Edge
prog.cpp:159:22: error: ‘min’ was not declared in this scope
           cap_t df = min<tcap_t>(excess[u], residue(e));
                      ^~~
prog.cpp:159:32: error: expected primary-expression before ‘>’ token
           cap_t df = min<tcap_t>(excess[u], residue(e));
                                ^
prog.cpp:159:34: error: ‘excess’ was not declared in this scope
           cap_t df = min<tcap_t>(excess[u], residue(e));
                                  ^~~~~~
prog.cpp:159:34: note: suggested alternative: ‘extern’
           cap_t df = min<tcap_t>(excess[u], residue(e));
                                  ^~~~~~
                                  extern
prog.cpp:162:24: error: ‘min’ was not declared in this scope
         } else delta = min<tcost_t>(delta, cost_p(u, e));
                        ^~~
prog.cpp:162:35: error: expected primary-expression before ‘>’ token
         } else delta = min<tcost_t>(delta, cost_p(u, e));
                                   ^
prog.cpp: In member function ‘void CostScaling<CapType, TotalCapType, CostType, TotalCostType>::construct()’:
prog.cpp:174:5: error: ‘ofs’ was not declared in this scope
     ofs.assign(N + 1, 0);
     ^~~
prog.cpp:175:5: error: ‘edges’ was not declared in this scope
     edges.resize(2 * in.size());
     ^~~~~
prog.cpp:175:5: note: suggested alternative: ‘Edge’
     edges.resize(2 * in.size());
     ^~~~~
     Edge
prog.cpp:175:22: error: ‘in’ was not declared in this scope
     edges.resize(2 * in.size());
                      ^~
prog.cpp:175:22: note: suggested alternative: ‘int’
     edges.resize(2 * in.size());
                      ^~
                      int
prog.cpp:176:5: error: ‘initial_excess’ was not declared in this scope
     initial_excess.assign(N, 0);
     ^~~~~~~~~~~~~~
prog.cpp:176:5: note: suggested alternative: ‘initial_cost’
     initial_excess.assign(N, 0);
     ^~~~~~~~~~~~~~
     initial_cost
prog.cpp:178:5: error: ‘potential’ was not declared in this scope
     potential.assign(N, 0);
     ^~~~~~~~~
prog.cpp:179:20: error: range-based ‘for’ expression of type ‘auto’ has incomplete type
     for (auto& e : in) ofs[e.from + 1]++, ofs[e.to + 1]++;
                    ^~
prog.cpp:181:20: error: range-based ‘for’ expression of type ‘auto’ has incomplete type
     for (auto& e : in) {
                    ^~
prog.cpp: In member function ‘bool CostScaling<CapType, TotalCapType, CostType, TotalCostType>::has_feasible_circulation()’:
prog.cpp:193:21: error: ‘ofs’ was not declared in this scope
     return Dinic(N, ofs, edges, capacity).succeeded();
                     ^~~
prog.cpp:193:26: error: ‘edges’ was not declared in this scope
     return Dinic(N, ofs, edges, capacity).succeeded();
                          ^~~~~
prog.cpp:193:26: note: suggested alternative: ‘Edge’
     return Dinic(N, ofs, edges, capacity).succeeded();
                          ^~~~~
                          Edge
prog.cpp:193:33: error: ‘capacity’ was not declared in this scope
     return Dinic(N, ofs, edges, capacity).succeeded();
                                 ^~~~~~~~
prog.cpp:193:33: note: suggested alternative: ‘cap_t’
     return Dinic(N, ofs, edges, capacity).succeeded();
                                 ^~~~~~~~
                                 cap_t
prog.cpp: At global scope:
prog.cpp:209:35: error: ‘int64_t’ was not declared in this scope
 using MCC = CostScaling<int, int, int64_t, int64_t>;
                                   ^~~~~~~
prog.cpp:209:44: error: ‘int64_t’ was not declared in this scope
 using MCC = CostScaling<int, int, int64_t, int64_t>;
                                            ^~~~~~~
prog.cpp:209:51: error: template argument 3 is invalid
 using MCC = CostScaling<int, int, int64_t, int64_t>;
                                                   ^
prog.cpp:209:51: error: template argument 4 is invalid
stdout
Standard output is empty