Search is not available for this dataset
name
stringlengths
2
88
description
stringlengths
31
8.62k
public_tests
dict
private_tests
dict
solution_type
stringclasses
2 values
programming_language
stringclasses
5 values
solution
stringlengths
1
983k
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#define _USE_MATH_DEFINES #include <iostream> #include <fstream> #include <cstdio> #include <cmath> #include <cstdlib> #include <cstring> #include <string> #include <vector> #include <utility> #include <complex> #include <set> #include <map> #include <queue> #include <stack> #include <deque> #include <tuple> #include <...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <cstdio> #include <algorithm> #include <vector> #include <queue> using namespace std; using Weight=long long; static const Weight INF=1LL<<57; template <class T> using gp_queue=priority_queue<T, deque<T>, less<T>>; struct Arc { // accessible to the reverse edge size_t src, dst; Weight capacity,...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> P; constexpr int IINF = INT_MAX; struct edge{ int to, cap, cost, rev; }; int V, E, F; vector<vector<edge> > G; vector<int> h, dist, prevv, preve; void add_edge(int from, int to, int cap, int cost){ G[from].push_back((edge){to, cap, cost, i...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
CORRECT
java
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.Closeable; import java.io.FileInputStream; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; impo...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
CORRECT
java
import java.awt.geom.Point2D; import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { Scanner sc = new Scanner(System.in); public static void main(String[] args){ new Main(); } public Main(){ // new A().doIt(); new GRL_6().doIt(); } class GRL_6{ void doIt(){ int n = sc.ne...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
CORRECT
java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.PriorityQueue; import java.util.Vector; public class Main { static final int INF = 10000000; /** * @param args * @throws IOException */ @SuppressWarnings("unchecked") publ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <bits/stdc++.h> #define pb push_back using namespace std; const int INF=0x3f3f3f3f; const int maxn=105; struct Edge { int from,to,cap,flow,cost; Edge(int u,int v,int c,int f,int w):from(u),to(v),cap(c),flow(f),cost(w) {} }; int n,m,tf; vector<Edge>edges; vector<int>G[maxn]; bool inq[maxn]; int d[maxn]; int...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; struct PrimalDual{ const int INF = 1<<28; typedef pair<int,int> P; struct edge{ int to,cap,cost,rev; edge(){} edge(int to,int cap,int cost,int rev):to(to),cap(cap),cost(cost),rev(rev){} }; int n; vector<vector<edge> > G; vector<int> h,dist,prevv,...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<iostream> using namespace std; //Minimum Cost Flow O(FE log V) #include<algorithm> #include<utility> #include<vector> #include<queue> #include<limits> template<typename T> struct MCF{ vector<vector<pair<pair<int,int>,pair<int,T> > > >G; vector<T>h,d; vector<int>pv,pe; MCF(int n_=0):G(n_),h(n_,0),d(n_),pv(n...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; #define int long long //O(F*V^2) class MinimumCostFlow { private: struct edge { int to, cap, cost, rev; }; const int INF = 1e18; int V; vector<vector<edge>> G; vector<int> h, dist; vector<int> prevv, preve; void add_edge(int from, int to, int cap, i...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; #define rep(i,n) REP(i,0,n) #define REP(i,s,e) for(int i=(s); i<(int)(e); i++) #define repr(i, n) REPR(i, n, 0) #define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--) #define pb push_back #define all(r) r.begin(),r.end() #define rall(r) r.rbegin(),r.rend() #def...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
CORRECT
cpp
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_B&lang=jp #include <iostream> #include <map> #include <queue> #include <vector> #include <algorithm> using namespace std; typedef pair<int, int>P; class MCF{ public: class edge{ public: int to, cap, cost, rev; edge(){}; edge(int _to, int _cap, ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
CORRECT
python3
from heapq import heappush, heappop import collections class MinCostFlowDijkstra: def __init__(self, N): self.N = N self.edges = collections.defaultdict(list) def add(self, fro, to, cap, cost, directed=True): # edge[fro]: to, cap, cost, rev(逆辺) if directed: self.ed...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <bits/stdc++.h> #define _overload(_1,_2,_3,name,...) name #define _rep(i,n) _range(i,0,n) #define _range(i,a,b) for(int i=int(a);i<int(b);++i) #define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__) #define _rrep(i,n) _rrange(i,n,0) #define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i) #define r...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<bits/stdc++.h> #define fi first #define se second typedef long long ll; using namespace std; //BEGIN CUT HERE //Min_cost_flow class Min_cost_flow{ public: explicit Min_cost_flow(int n):vertex(static_cast<unsigned int>(n+10)){ G.resize(vertex); prev_e.resize(vertex); prev_v.resize(v...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
CORRECT
python3
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools import time,random sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 mod2 = 998244353 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return lis...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <bits/stdc++.h> static const int MAX=100; static const int INFTY=(1<<30); class edge{ public: int target, cap, cost, rev; edge(int target = 0, int cap =0, int cost = 0, int rev =0) : target(target), cap(cap), cost(cost), rev(rev) {} }; int V; std::vector<edge> G[MAX]; int h[MAX], dist[MAX], prevv[MAX],...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <iostream> #include <fstream> #include <string> #include <vector> #include <queue> #include <stack> #include <map> #include <algorithm> #include <sstream> #include <cmath> #include <set> #include <iomanip> #include <deque> #include <stdio.h> using namespace std; #define REP(i,n) for(int (i)=0;(i)<(int)(n);(i...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <cassert> #include <iostream> #include <vector> #include <queue> #include <utility> #include <tuple> #include <limits> using namespace std; struct MinCostFlowGraph { private: using ll = long long; struct edge { int to; ll cap, cost; int r_idx; edge(int t, ll cap, ll cost, int r) : to...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template<typename T, T INF> class MinCostFlow{ public: //辺を表す構造体(行き先、容量、コスト、逆辺) struct edge{ int to,cap; T cost; int rev; edge(); edge(int to,int cap,T cost,int rev):to(to),cap(cap),cost(cost),rev(rev){} }; int V; ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop; void main() { auto s = readln.split.map!(to!int); auto V = s[0]; auto E = s[1]; auto F = s[2]; auto mcf = new MinCostF...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using i64 = long long; struct edge { i64 from; i64 to; i64 cap; i64 cost; i64 rev; }; i64 INF = 1e18; i64 capacity_scaling_bflow(std::vector<std::vector<edge>>& g, std::vector<i64> b) { i64 ans = 0; i64 U = *std::max_element(begin(b)...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using i64 = long long; struct edge { i64 from; i64 to; i64 cap; i64 cost; i64 rev; }; i64 INF = 1e8; i64 capacity_scaling_bflow(std::vector<std::vector<edge>>& g, std::vector<i64> b) { i64 ans = 0; i64 U = *std::max_element(begin(b),...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using i64 = long long; struct edge { i64 from; i64 to; i64 cap; i64 cost; i64 rev; }; i64 INF = 1e8; i64 capacity_scaling_bflow(std::vector<std::vector<edge>>& g, std::vector<i64> b) { i64 ans = 0; i64 U = *std::max_element(begin(b),...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
class PQueue attr_accessor :node def initialize @node = [] end def insert(num) i = @node.size @node[i] = num down_heap(i) end def extract ret = @node[0] if @node.size > 1 @node[0] = @node.pop() up_heap(0) else @node = [] end return ret end def delete...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
from heapq import heappop, heappush def trace(source, edge_trace): v = source for i in edge_trace: e = edges[v][i] yield e v = e[1] def min_cost_flow(source, sink, required_flow): res = 0 while required_flow: visited = set() queue = [(0, source, tuple())] ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> struct node { int id; int cap; int cost; struct node *next; }; struct node **list; int **flow, *delta, *dist, *prev; int *heap, *heap_index, heapsize; void Insert(int, int, int, int); void downheap(int); void upheap(int); void PQ_init(int); int PQ_remove(void); void PQ_update(int); int ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
// warm heart, wagging tail,and a smile just for you! // ███████████ // ███╬╬╬╬╬╬╬╬╬╬███ // ███╬╬╬╬╬╬╬██╬╬╬╬╬╬███ // ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using Int = int64_t; using UInt = uint64_t; using C = std::complex<double>; template <typename T> using RQ = std::priority_queue<T, std::vector<T>, std::greater<T>>; int main() { Int v, e, f; std::cin >> v >> e >> f; std::vector<Int> ss(e + 1), ts(e + 1), cs(e + 1), fs(e + 1), bs(e + 1); ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; struct edge { int to, cap, cost, rev; }; static const int MAX_V = 10000; int V; vector<edge> G[MAX_V]; int dist[MAX_V]; int prevv[MAX_V], preve[MAX_V]; void addEdge(int from, int to, int cap, int cost) { G[from].push_back((edge{to, cap, cost, (int)G[to].size()})); G[t...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using Int = int64_t; using UInt = uint64_t; using C = std::complex<double>; template <typename T> using RQ = std::priority_queue<T, std::vector<T>, std::greater<T>>; int main() { Int v, e, f; std::cin >> v >> e >> f; std::vector<Int> ss(e + 1), ts(e + 1), cs(e + 1), fs(e + 1), bs(e + 1); ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <stdexcept> #include <cmath> #include <utility> #include <queue> #include <limits> #include <iostream> #include <vector> #include <cstddef> #include <type_traits> namespace loquat { using vertex_t = size_t; } namespace loquat { namespace edge_param { struct to_ { vertex_t to; explicit to_(vertex_t t = 0) :...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
from heapq import heappop, heappush def trace(source, edge_trace): v = source for i in edge_trace: e = edges[v][i] yield e v = e[1] def min_cost_flow(source, sink, required_flow): res = 0 while required_flow: dist = [-1] * n queue = [(0, source, tuple())] ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using ll = long long; using ld = long double; template <class T, class S> void cmin(T &a, const S &b) { if (a > b) a = b; } template <class T, class S> void cmax(T &a, const S &b) { if (a < b) a = b; } ll dx[] = {0, 0, 1, -1}; ll dy[] = {1, -1, 0, 0}; ll W, H; bool inrange(ll x, ll y) { ret...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using i64 = long long; struct edge { i64 from; i64 to; i64 cap; i64 cost; i64 rev; }; i64 INF = 1e18; i64 capacity_scaling_bflow(std::vector<std::vector<edge>>& g, std::vector<i64> b) { i64 ans = 0; i64 U = *std::max_element(begin(b)...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <iostream> #include <vector> using namespace std; constexpr int INF = 1e9; struct Edge { int to, cap, rev, weight; Edge(int t, int c, int r, int w) : to(t), cap(c), rev(r), weight(w){} }; using Edges = vector<Edge>; using Graph = vector<Edges>; class Flow { public: Flow(int v){ ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; static const int MAX_V = 110; static const int INF = (1 << 30); struct edge { int to, cap, cost, rev; }; int V; vector<edge> G[MAX_V]; int h[MAX_V], dist[MAX_V], prevv[MAX_V], preve[MAX_V]; void add_edge(int from, int to, int cap, int cost) { G[from].push_back((edge){to...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace MinimumCostFlow { class Edge : IComparable { internal int from, to, cap, cost; public Edge(int from, int to) { this.from = from; this.to = to; } publ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int maxN = 1100; bool mark[maxN]; int parentEdge[maxN], dis[maxN]; int n, k, m, st, fn, F, remFlow; struct edge { int u, v, weight, cap; }; vector<int> g[maxN]; edge e[maxN * maxN]; int curID = 0; edge make_edge(int u, int v, int w, int cap) { edge e; e.u = u; ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; namespace MCF { const int MAXN = 120; const int MAXM = 2100; int to[MAXM]; int next[MAXM]; int first[MAXN]; int c[MAXM]; long long w[MAXM]; long long pot[MAXN]; int rev[MAXM]; long long ijk[MAXN]; int v[MAXN]; long long toc; int tof; int n; int m; void init(int _n) { n = ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } template <class A, size_t N, class T> void Fill(A (&a)[N],...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include<iostream> #include<vector> #include<string> #include<algorithm> #include<map> #include<set> #include<utility> #include<cmath> #include<cstring> #include<queue> #include<cstdio> #include<sstream> #define loop(i,a,b) for(int i=a;i<b;i++) #define rep(i,a) loop(i,0,a) #define pb push_back #define mp make_pair #de...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using i64 = long long; struct edge { i64 from; i64 to; i64 cap; i64 cost; i64 rev; }; i64 INF = 1e8; i64 capacity_scaling_bflow(std::vector<std::vector<edge>>& g, std::vector<i64> b) { i64 ans = 0; i64 U = *std::max_element(begin(b),...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.io.*; import java.util.*; public class Main implements Runnable{ private ArrayList<ArrayList<Integer>> graph; private Edge[] edges; public static void main(String[] args) throws Exception { new Thread(null, new Main(), "bridge", 16 * 1024 * 1024).start(); } @Override public...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int maxN = 1100; bool mark[maxN]; int parentEdge[maxN], dis[maxN]; int n, k, m, st, fn, F, remFlow; struct edge { int u, v, weight, cap; }; vector<int> g[maxN]; edge e[maxN * maxN]; int curID = 0; edge make_edge(int u, int v, int w, int cap) { edge e; e.u = u; ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
v_num, e_num, flow = (int(n) for n in input().split(" ")) edges = defaultdict(list) for _ in range(e_num): s1, t1, cap, cost = (int(n) for n in input().split(" ")) edges[s1].append([t1, cap, cost, len(edges[t1])]) edges[t1].append([s1, cap, cost, len(edges[s1])]) answer = 0 before_vertice = [float("inf") fo...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; struct Edge { Edge(int arg_to, int arg_capacity, int arg_cost, int arg_rev_index) { to = arg_to; capacity = arg_capacity; cost = arg_cost; rev_index = arg_rev_index; } int to, capacity, cost, rev_index; }; int V; vector<Edge> G[100]; int h[100]; int di...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include<vector> #include<queue> #include<algorithm> #define MAX 101 #define inf 1<<29 using namespace std; typedef pair<int,int> P; struct edge{ int to,cap,cost,rev; }; int v; vector<edge> e[MAX]; int h[MAX]; int dist[MAX]; int prevv[MAX],preve[MAX]; void add_edge(int from,int to,int cap,int cost){ e[from].push_...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <typename T> class min_cost_flow { public: struct edge { int to, cap; T cost; int rev; }; using pti = pair<T, int>; vector<vector<edge> > G; vector<T> h, dist; vector<int> prevv, preve; T inf; int V; min_cost_flow(int node_size) { ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
ああ
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int INF = 1 << 30; typedef struct { int to, cap, cost, rev; } Edge; class MinCostFlow { private: int V; vector<vector<Edge>> G; public: MinCostFlow(int V) : V(V) { G.resize(V); } void add_edge(int u, int v, int c, int d) { G[u].push_back({v, c, d, (in...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using LL = long long; constexpr LL LINF = 334ll << 53; constexpr int INF = 15 << 26; constexpr LL MOD = 1E9 + 7; class MinimumCostFlow { struct Edge { int to; long long cost, capacity; int rev_id; Edge(int to, long long cost, long long cap, int id) ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using Int = int64_t; using UInt = uint64_t; using C = std::complex<double>; template <typename T> using RQ = std::priority_queue<T, std::vector<T>, std::greater<T>>; int main() { Int v, e, f; std::cin >> v >> e >> f; std::vector<Int> ss(e + 1), ts(e + 1), cs(e + 1), fs(e + 1), bs(e + 1); ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> struct node { int id; int cap; int cost; struct node *next; }; struct node **list; int **flow, *dist, *prev, *preve, *h; int *heap, *heap_index, heapsize; void Insert(int, int, int, int); void downheap(int); void upheap(int); void PQ_init(int); int PQ_remove(void); void PQ_update(int); ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int maxn = 105; struct Edge { int from, to, cap, flow, cost; Edge(int u, int v, int c, int f, int w) : from(u), to(v), cap(c), flow(f), cost(w) {} }; int n, m, tf; vector<Edge> edges; vector<int> G[maxn]; bool inq[maxn]; int d[max...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; struct edge { int to, cap, cost, rev; }; int V; vector<edge> G[100]; vector<int> h(100); int dist[100]; int prevv[100], preve[100]; void add_edge(int from, int to, int cap, int cost) { G[from].push_back((edge){to, cap, cost, (int)G[to].size()}); G[to].push_back((edge)...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int MAX = 100; const int INF = 1 << 25; class edge { public: int to, cap, cost, rev; edge() {} edge(int to, int cop, int cost, int rev) : to(to), cap(cap), cost(cost), rev(rev) {} }; int V; vector<edge> G[MAX]; int h[MAX]; int dist[MAX]; int prevv[MAX], p...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
python2
''' import numpy as np import matplotlib.pyplot as plt import seaborn as sns import pandas as pd import sys import csv import argparse import time ''' import heapq INF = sys.maxint/3 class Edge: def __init__(self, to, cap, cost, rev): self.to = to self.cap = cap self.cost = cost se...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int v, e; vector<pair<int, int> > adj[110], revadj[110]; int capacity[1010], cost[1010], flowingthrough[1010], dis[110], pre[110], preedge[110], endofedge[1010]; void bellmanford() { fill_n(dis, v, 1e9); dis[0] = 0; for (int i = 0; i < v; i++) { for (auto e : ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
from heapq import heappop, heappush def trace(source, edge_trace): v = source for i in edge_trace: e = edges[v][i] yield e v = e[1] def min_cost_flow(source, sink, required_flow): res = 0 while required_flow: dist = [-1] * n queue = [(0, source, tuple())] ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
from collections import defaultdict v_num, e_num, flow = (int(n) for n in input().split(" ")) edges = defaultdict(list) for _ in range(e_num): s1, t1, cap, cost = (int(n) for n in input().split(" ")) edges[s1].append([t1, cap, cost, len(edges[t1])]) edges[t1].append([s1, cap, cost, len(edges[s1])]) answer ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long long int INF = 2000000000; struct edge { int to, cap, cost, rev; edge(int t, int ca, int co, int re) { to = t; cap = ca; cost = co; rev = re; } }; vector<edge> G[40]; int prv[40], pre[40], d[40]; int v, e, flow; void addedge(int from, int to...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> struct min_cost_flow_graph { struct edge { int from, to; T cap, f; U cost; }; vector<edge> edges; vector<vector<int>> g; int n, st, fin; T required_flow, flow; U cost; min_cost_flow_graph(int n, int st, int fin, ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; constexpr int INF = 1e9; struct Edge { int to, cap, rev, weight; Edge(int t, int c, int r, int w) : to(t), cap(c), rev(r), weight(w) {} }; using Edges = vector<Edge>; using Graph = vector<Edges>; class Flow { public: Flow(int v) { mGraph.resize(v); mUsed.assi...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.PriorityQueue; import java.util.Scanner; @SuppressWarnings("unchecked") class MinCostFlow{ class Edge{ int to,cap,cost,rev; Edge(int to,int cap,int cost,int rev){this.to=to;this.cap=cap;this.cost=cost;this....
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
from heapq import heappop, heappush def trace(source, edge_trace): v = source for i in edge_trace: e = edges[v][i] yield e v = e[1] def min_cost_flow(source, sink, required_flow): res = 0 while required_flow: visited = set() queue = [(0, source, tuple())] ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; class Edge { public: int from; int to; int flow; Edge(int f, int t, int d) { from = f; to = t; flow = d; } }; class Shortest_path_result { public: int sum_of_cost; vector<int> path; vector<int> distance; vector<int> predecessor; Shortest_pa...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long long INF = (1ll << 60); struct Edge { long long s, t, c, d, u; }; long long minCostFlow(vector<vector<Edge>> &G, long long s, long long t, long long F) { long long V = G.size(); long long cost = 0; while (F) { vector<long long> d...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
from collections import defaultdict import sys sys.setrecursionlimit(200000) def dfs(source, used, all_weight, connect): max_weight = all_weight max_source = source used[source] = 1 for target, weight in connect[source]: if not used[target]: now_weight = all_weight + weight ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; namespace MCF { const int MAXN = 120; const int MAXM = 2100; int to[MAXM]; int next[MAXM]; int first[MAXN]; int c[MAXM]; int w[MAXM]; int pot[MAXN]; int rev[MAXM]; int ijk[MAXN]; int v[MAXN]; int toc; int tof; int n; int m; void init(int _n) { n = _n; for (int i = 0; i ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC target("avx") using namespace std; template <typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2> p) { o << "(" << p.first << ":" << p.second << ")"; return o; } template <typename iterator> inline size_t argmin(iterator begin, ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using i64 = long long; struct edge { i64 from; i64 to; i64 cap; i64 cost; i64 rev; }; i64 INF = 1e18; i64 capacity_scaling_bflow(std::vector<std::vector<edge>>& g, std::vector<i64> b) { i64 ans = 0; i64 U = *std::max_element(begin(b)...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; namespace { template <class T> ostream& operator<<(ostream& os, const vector<T>& vs) { if (vs.empty()) return os << "[]"; auto i = vs.begin(); os << "[" << *i; for (++i; i != vs.end(); ++i) os << " " << *i; return os << "]"; } template <class T> istream& operator>...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007LL; const int inf = 1e9; const long long INF = 1e18; const int MAX_V = 100; struct edge { int to, cap, cost, rev; edge(int to, int cap, int cost, int rev) : to(to), cap(cap), cost(cost), rev(rev) {} }; vector<edge> G[MAX_V]; int h[M...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; constexpr int INF = 10000000; constexpr int MAX = 1000000; struct Edge { int to; int cap; int cost; int rev; Edge(int to, int cap, int cost, int rev) : to(to), cap(cap), cost(cost), rev(rev) {} }; int V, E, F; vector<Edge> G[MAX]; int h[MAX]; int dist[MAX]; ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; class Edge { public: int from; int to; int flow; Edge(int f, int t, int d) { from = f; to = t; flow = d; } }; class Shortest_path_result { public: int sum_of_cost; vector<int> path; vector<int> distance; vector<int> predecessor; Shortest_pa...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; struct Order { bool operator()(pair<long, long> const& a, pair<long, long> const& b) const { return a.first > b.first || ((a.first == b.first) && (a.second > b.second)); } }; struct edge { long to, cap, dis, rev; }; class Primal_dual { private: vector<vector<ed...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; class Edge { public: int from; int to; int flow; Edge(int f, int t, int d) { from = f; to = t; flow = d; } }; class Shortest_path_result { public: int sum_of_cost; vector<int> path; vector<int> distance; vector<int> predecessor; Shortest_pa...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
// clang-format off #include <bits/stdc++.h> using namespace std; #define int long long #define main signed main() #define loop(i, a, n) for (int i = (a); i < (n); i++) #define rep(i, n) loop(i, 0, n) #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define prec(n) fixed << setprecision(n)...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.Closeable; import java.io.FileInputStream; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; impo...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using i64 = long long; struct edge { i64 from; i64 to; i64 cap; i64 cost; i64 rev; }; i64 INF = 1e18; i64 capacity_scaling_bflow(std::vector<std::vector<edge>>& g, std::vector<i64> b) { i64 ans = 0; i64 U = *std::max_element(begin(b)...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; struct SuccessiveShortestPath { struct Edge { int to, cap, cost, rev; }; int n, init; vector<vector<Edge>> g; vector<int> dist, pv, pe; SuccessiveShortestPath() {} SuccessiveShortestPath(int n, int INF = 1e9) : n(n), g(n), init(INF), dist(n), pv(n), ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using vi = vector<int>; template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "sz=" << v.size() << "\n["; for (const auto& p : v) { os << p << ","; } os << "]\n"; return os; } templ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
class PQueue attr_accessor :node def initialize @node = [] end def insert(num) i = @node.size @node[i] = num down_heap(i) end def extract ret = @node[0] if @node.size > 1 @node[0] = @node.pop() up_heap(0) else @node = [] end return ret end def delete...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; class Edge { public: int from; int to; int flow; Edge(int f, int t, int d) { from = f; to = t; flow = d; } }; class Shortest_path_result { public: int sum_of_cost; vector<int> path; vector<int> distance; vector<int> predecessor; Shortest_pa...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int INFL = (int)1e9; const long long int INFLL = (long long int)1e18; const double INFD = numeric_limits<double>::infinity(); const double PI = 3.14159265358979323846; bool nearlyeq(double x, double y) { return abs(x - y) < 1e-9; } bool inrange(int x, int t) { return ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.Comparator; import java.util.InputMismatchException; import java.util.TreeSet; public class Main { static InputStream is; static PrintWriter out; static ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <iostream> #include <vector> #define inf 1000000000 using namespace std; struct edge{ int to, cap, cost, rev; edge(int a, int b, int c, int d){ to = a, cap = b, cost = c, rev = d; } }; int V, E, F; vector<edge> G[1005]; int dist[1005], prev[1005], prev_e[1005]; void BellmanFord() { int v; bool updat...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> #define pb push_back using namespace std; const int INF=0x3f3f3f3f; const int maxn=105; const int maxq=1005; struct edge{int to,cap,cost,rev;}; int n,m,k; int d[maxn]; int a[maxn]; int p1[maxn]; int p2[maxn]; bool inq[maxn]; vector<edge>G[maxn]; void add_edge(int u,int v,int c,int w) { G[u]...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f; const int MOD = (int)(1e9) + 7; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template <class T> bool chmin(T &a, c...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include<iostream> #include<vector> #include<queue> #include<algorithm> #define MAX 101 #define inf 1<<29 using namespace std; typedef pair<int,int> P; struct edge{ int to,cap,cost,rev; }; int v; vector<edge> e[MAX]; int h[MAX]; int dist[MAX]; int prevv[MAX],preve[MAX]; void add_edge(int from,int to,int cap,int cos...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using LL = long long; constexpr LL LINF = 334ll << 53; constexpr int INF = 15 << 26; constexpr LL MOD = 1E9 + 7; struct Edge { int from, to; LL cost, capacity; int rev_id; }; struct Prev { LL cost; int from, id; }; class MinimumCostFlow { struct Edge { int t...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> struct node { int id; int cap; int cost; struct node *next; }; struct node **list; int **flow, *delta, *dist, *prev; int *heap, *heap_index, heapsize; void Insert(int, int, int, int); void downheap(int); void upheap(int); void PQ_init(int); int PQ_remove(void); void PQ_update(int); int ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using i64 = long long; struct edge { i64 from; i64 to; i64 cap; i64 cost; i64 rev; }; i64 INF = 1e8; i64 capacity_scaling_bflow(std::vector<std::vector<edge>>& g, std::vector<i64> b) { i64 ans = 0; i64 U = *std::max_element(begin(b),...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int INF = 1 << 29; void print_adjacency_list( const vector<vector<tuple<int, int, int, int> > > &adj) { cout << "st_nd: (ed_nd, capa, cost, st_ind), ..." << endl; for (int st_nd = 0; st_nd < adj.size(); ++st_nd) { cout << st_nd << ":"; for (auto itr = ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using Int = long long; template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; } template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; } template <typename T> struct PrimalDual { struct edge { int to;...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; namespace MCF { const int MAXN = 120; const int MAXM = 2100; int to[MAXM]; int next[MAXM]; int first[MAXN]; int c[MAXM]; long long w[MAXM]; long long pot[MAXN]; int rev[MAXM]; long long ijk[MAXN]; int v[MAXN]; long long toc; int tof; int n; int m; void init(int _n) { n = ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
// warm heart, wagging tail,and a smile just for you! // ███████████ // ███╬╬╬╬╬╬╬╬╬╬███ // ███╬╬╬╬╬╬╬██╬╬╬╬╬╬███ // ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using Vertex = int; using Flow = long double; using Cost = long double; const Flow FLOW_INF = LDBL_MAX; const Cost COST_INF = LDBL_MAX; struct Edge { Vertex from, to; Flow capacity; Cost cost; int rev; Edge(Vertex from, Vertex to, Flow capacity = 0, Cost cost = 0, int rev = -1) ...
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; class Networkflow { private: struct edgedata { int from, to, capacity, weight; edgedata* dual_p; bool operator<(const edgedata& another) const { return (weight != another.weight ? weight < another.weight : capacity...