网络流萌新,蒟蒻求调。
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 205, M = 2005, inf = 1e18;
int n, m, x, u, v, z, fir[N], son[M << 1], nxt[M << 1], w[M << 1], ans, tem, tt, d[N], tot = 1, q[N], t, h, now[N];
inline void add(int x, int y, int z){
nxt[++tot] = fir[x];
fir[x] = tot;
son[tot] = y;
w[tot] = z;
}
inline bool bfs(){
for(int i = 1; i <= n; i++) d[i] = 0;
for(int i = 1; i <= n; i++) now[i] = fir[i];
h = 0;
q[t = 1] = 1;
d[1] = 1;
while(h < t){
h++;
for(int i = now[q[h]]; i ; i = nxt[i]){
if(w[i] && !d[son[i]]){
d[son[i]] = d[q[h]] + 1;
q[++t] = son[i];
if(son[i] == n) return 1;
}
}
}
return 0;
}
inline int dinic(int flow, int x){
int res = flow;
if(x == n) return flow;
for(int i = now[x]; i ; i = nxt[i]){
now[x] = i;
if(w[i] && d[son[i]] != d[x] + 1){
tt = dinic(min(res, w[i]), son[i]);
if(!tt) continue ;
res -= tt;
w[i] -= tt;
w[i ^ 1] += tt;
}
}
return flow - res;
}
signed main(){
scanf("%lld%lld%lld", &n, &m, &x);
for(int i = 1; i <= m; i++){
scanf("%lld%lld%lld", &u, &v, &z);
add(u, v, z);
add(v, u, 0);
}
while(bfs()){
if(tem = dinic(inf, 1)) ans += tem;
else break;
}
if(ans == 0) printf("Orz Ni Jinan Saint Cow!");
else printf("%lld %lld", ans, (x + ans - 1) / ans);
return 0;
}