Isprime @ 2019-12-09 14:33:25
rt,Dinic死循环了 /kel
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
const int MAXN = 10001;
const int MAXM = 100001;
const int INF = 2147483647;
int n, m, s, t, edge_cnt = 1;
int head[MAXN];
int dep[MAXN];
bool vis[MAXN];
struct Edge {
int to, next, dis;
}edge[MAXM << 1];
inline void addedge(int from, int to, int dis) {
edge[++edge_cnt].next = head[from];
edge[edge_cnt].dis = dis;
edge[edge_cnt].to = to;
head[from] = edge_cnt;
}
inline bool bfs() {
memset(dep, 0x3f, sizeof(dep));
memset(vis, 0, sizeof(vis));
dep[s] = 0;
queue <int> q;
q.push(s);
while(!q.empty()) {
int u = q.front();
q.pop();
vis[u] = 0;
for(register int i = head[u]; i; i = edge[i].next) {
int v = edge[i].to;
if(dep[v] > dep[u] + 1 && edge[i].dis) {
dep[v] = dep[u] + 1;
if(!vis[v]) {
q.push(v);
vis[v] = 1;
}
}
}
}
if(dep[t] != 0x3f) return 1;
return 0;
}
inline int dfs(int u, int flow) {
int rlow = 0;
if(u == t) return flow;
for(register int i = head[u]; i; i = edge[i].next) {
int d = edge[i].to;
if(edge[i].dis && dep[d] == dep[u] + 1)
if(rlow = dfs(d, min(flow, edge[i].dis))) {
edge[i].dis -= rlow;
edge[i ^ 1].dis += rlow;
return rlow;
}
}
return 0;
}
inline int Dinic(int s, int t) {
int maxflow = 0, lowflow;
while(bfs()) {
while(lowflow = dfs(s, INF)) maxflow += lowflow;
}
return maxflow;
}
signed main() {
scanf("%d%d%d%d", &n, &m, &s, &t);
for(register int u, v, w, i = 1; i <= m; ++i) {
scanf("%d%d%d", &u, &v, &w);
addedge(u, v, w);
addedge(v, u, 0);
}
printf("%d\n", Dinic(s, t));
return 0;
}
by SKTelecomT1_Faker @ 2019-12-09 14:33:50
orz Isprime
by SKTelecomT1_Faker @ 2019-12-09 14:35:02
%%%
by 血色黄昏 @ 2019-12-09 14:35:17
orz isprime
by 血色黄昏 @ 2019-12-09 14:35:27
isprime AK IOI!
by 不摇碧莲 @ 2019-12-09 14:37:37
orz isprime
isprime AK IOI
by 星辰丶Z @ 2019-12-09 14:42:21
orz
by 血色黄昏 @ 2019-12-09 14:46:48
评论的都是巨佬
by yummy @ 2019-12-09 14:59:54
Orz
by hly1204 @ 2019-12-09 15:01:09
%
by DeepSkyBlue__ @ 2019-12-09 18:01:27
Orz Isprime