正文
增加 11 行删除 12 行
1234567858 行未改动67686970717273747523 行未改动9910010110210310410510610737 行未改动145146147148149150151152153169 行未改动全部展开32332432532632732832933033151 行未改动38338438538638738838939039185 行未改动4774784794804814824834844859 行未改动495496497498499500501502503415 行未改动全部展开919920921922923924925926927113 行未改动全部展开104110421043104410451046104710481049115 行未改动全部展开1165116611671168116911701171::::success[结算画面]$2$ 蓝 $6$ 紫,刺不刺激?::::让我们,开始通关网络流全家桶吧!58 行未改动bool vis[N];int incf[N], pre[N], mf;//incf:到这个点可以允许的最大流量,pre:在增广路上这个点的前驱节点queue<int> q;bool bfs() {//bfs找增广路while(!q.empty()) q.pop();memset(vis, false, sizeof vis);q.push(s);vis[s] = true;incf[s] = INF;//源点初始可以流出无限的流量,所以这里是 INF23 行未改动e[i ^ 1].w += incf[t];//记住,这里一定是增流,不要写成 -= incf[t]!!!u = e[i ^ 1].to;}mf += incf[t];//累加最大流}}signed main() {memset(head, -1, sizeof head);ios :: sync_with_stdio(0);37 行未改动struct node { int to, w, nex; } e[M];int head[N], tot = -1;void adde(int u, int v, int w) {e[++ tot] = {v, w, head[u]};head[u] = tot;}int mf, dep[N];queue<int> q;bool bfs(int s) {//bfs 分层169 行未改动全部展开struct node { int to, w, nex; } e[M];int head[N], tot = -1;void adde(int u, int v, int w) {e[++ tot] = {v, w, head[u]};head[u] = tot;}int mf, dep[N];queue<int> q;bool bfs(int s) {51 行未改动int ans = 0;for(int b = 28; b >= 0; b -= 4) {//按 4 位划分for(int u = 1; u <= n; u++) {for(int v = u + 1; v <= n; v++) {if((mp[u][v] > 0 || mp[v][u] > 0) &&(mp[u][v] >= (1 << b) || mp[v][u] >= (1 << b))) {adde(u, v, mp[u][v]);//添加双向边adde(v, u, mp[v][u]);mp[u][v] = 0;//清除这条边,避免以后加上去第二遍85 行未改动}}vis[u] = false;//这一句千万不要漏了,不然这一个节点无法重复访问,多路增广也就用不了了return flow - delta;}int mflow, mcost;void dinic() {while(spfa(s)) {memcpy(cur, head, sizeof head);9 行未改动cin >> n >> m >> s >> t;for(int i = 1; i <= m; i++) {int u, v, w, c;cin >> u >> v >> w >> c;adde(u, v, w, c);}dinic();cout << mflow << " " << mcost << endl;return 0;415 行未改动全部展开```cpp#include <bits/stdc++.h>#define fi first#define se second#define endl '\n'using namespace std;const int N = 500 + 10;const int M = 1500 + 10;const int INF = 0x3f3f3f3f;113 行未改动全部展开cin >> Q;while(Q--) {int u, v;cin >> u >> v;u ++; v ++;cout << cut[u][v] << endl;}return 0;}115 行未改动全部展开S = s, T = t, sum = 0;//清零最大流dinic();cout << sum << " " << ans << endl;return 0;}```::::123456758 行未改动66676869707172737423 行未改动989910010110210310410510637 行未改动144145146147148149150151152169 行未改动全部展开32232332432532632732832933051 行未改动38238338438538638738838939085 行未改动4764774784794804814824834849 行未改动494495496497498499500501502415 行未改动全部展开918919920921922923924925926113 行未改动全部展开104010411042104310441045104610471048115 行未改动全部展开1164116511661167116811691170# 0x0 开头::::success[结算画面]::::让我们,开始通关网络流全家桶吧!58 行未改动bool vis[N];int incf[N], pre[N], mf;//incf:到这个点可以允许的最大流量,pre:在增广路上这个点的前驱节点queue<int> q;bool bfs() {//bfs找增广路while(!q.empty()) q.pop();memset(vis, false, sizeof vis);q.push(s);vis[s] = true;incf[s] = INF;//源点初始可以流出无限的流量,所以这里是 INF23 行未改动e[i ^ 1].w += incf[t];//记住,这里一定是增流,不要写成 -= incf[t]!!!u = e[i ^ 1].to;}mf += incf[t];//累加最大流}}signed main() {memset(head, -1, sizeof head);ios :: sync_with_stdio(0);37 行未改动struct node { int to, w, nex; } e[M];int head[N], tot = -1;void adde(int u, int v, int w) {e[++ tot] = {v, w, head[u]};head[u] = tot;}int mf, dep[N];queue<int> q;bool bfs(int s) {//bfs 分层169 行未改动全部展开struct node { int to, w, nex; } e[M];int head[N], tot = -1;void adde(int u, int v, int w) {e[++ tot] = {v, w, head[u]};head[u] = tot;}int mf, dep[N];queue<int> q;bool bfs(int s) {51 行未改动int ans = 0;for(int b = 28; b >= 0; b -= 4) {//按 4 位划分for(int u = 1; u <= n; u++) {for(int v = u + 1; v <= n; v++) {if((mp[u][v] > 0 || mp[v][u] > 0) &&(mp[u][v] >= (1 << b) || mp[v][u] >= (1 << b))) {adde(u, v, mp[u][v]);//添加双向边adde(v, u, mp[v][u]);mp[u][v] = 0;//清除这条边,避免以后加上去第二遍85 行未改动}}vis[u] = false;//这一句千万不要漏了,不然这一个节点无法重复访问,多路增广也就用不了了return flow - delta;}int mflow, mcost;void dinic() {while(spfa(s)) {memcpy(cur, head, sizeof head);9 行未改动cin >> n >> m >> s >> t;for(int i = 1; i <= m; i++) {int u, v, w, c;cin >> u >> v >> w >> c;adde(u, v, w, c);}dinic();cout << mflow << " " << mcost << endl;return 0;415 行未改动全部展开```cpp#include <bits/stdc++.h>#define fi first#define se second#define endl '\n'using namespace std;const int N = 500 + 10;const int M = 1500 + 10;const int INF = 0x3f3f3f3f;113 行未改动全部展开cin >> Q;while(Q--) {int u, v;cin >> u >> v;u ++; v ++;cout << cut[u][v] << endl;}return 0;}115 行未改动全部展开S = s, T = t, sum = 0;//清零最大流dinic();cout << sum << " " << ans << endl;return 0;}```::::