From 21a9a79889219ec496e46a5a98a2c503cc98d06e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E5=AE=87=E8=BE=B0?= Date: Thu, 22 Dec 2016 12:53:17 +0800 Subject: [PATCH] reduced memory --- Algorithms/Graph/NetworkFlow/ISAP_no_pointers.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Algorithms/Graph/NetworkFlow/ISAP_no_pointers.cpp b/Algorithms/Graph/NetworkFlow/ISAP_no_pointers.cpp index 0b67a4e..c3c6ba0 100644 --- a/Algorithms/Graph/NetworkFlow/ISAP_no_pointers.cpp +++ b/Algorithms/Graph/NetworkFlow/ISAP_no_pointers.cpp @@ -2,13 +2,12 @@ #include inline int min(int a, int b) { return a < b ? a : b; } const int maxn = 210; -int head[maxn], from[maxn << 1], to[maxn << 1], cap[maxn << 1], next[maxn << 1], ecnt, m, n; +int head[maxn], to[maxn << 1], cap[maxn << 1], next[maxn << 1], ecnt, m, n; int d[maxn], que[maxn], cur[maxn], num[maxn], fa[maxn]; inline void addEdge(int f, int t, int c) { next[ecnt] = head[f]; head[f] = ecnt; - from[ecnt] = f; to[ecnt] = t; cap[ecnt] = c; ecnt++; @@ -30,9 +29,9 @@ int ISAP(int s, int e) if (x == e) { int curFlow = 0x3f3f3f3f; - for (x = e; x != s; x = from[fa[x]]) + for (x = e; x != s; x = to[fa[x] ^ 1]) curFlow = min(curFlow, cap[fa[x]]); - for (x = e; x != s; x = from[fa[x]]) + for (x = e; x != s; x = to[fa[x] ^ 1]) cap[fa[x]] -= curFlow, cap[fa[x] ^ 1] += curFlow; flow += curFlow; x = s; @@ -49,7 +48,7 @@ int ISAP(int s, int e) if (--num[d[x]] == 0) break; num[d[x] = mn + 1]++; cur[x] = head[x]; - if (x != s) x = from[fa[x]]; + if (x != s) x = to[fa[x] ^ 1]; } } return flow;