include iostream include vector include queue using namespace std vect

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include <vector>
#include <queue>
в
using namespace std;
vector <int> d;
vector <vector <int, int>> g;
vector <vector <int, int>> e;
int n, t;
bool bfs () {
d.assign (n, -1);
queue <int> q;
d[0] = 0;
q.push (0);
while (!q.empty ()) {
int curVertex = q.front ();
q.pop ();
for (int i = 0; i < g[curVertex].size (); ++i) {
int nextVertex = g[curVertex][i];
if (e[nextVertex].flow < e[nextVertex].capacity && d[e[nextVertex].to] == -1) {
q.push (e[nextVertex].to);
d[e[nextVertex].to] = d[curVertex] + 1;
}
}
if (d[t] != -1)
return 1;
else
return 0;
}
}
int dfs (int curVertex, int flow) {
if (v == t)
return flow;
if (!flow)
return 0;
for (; ptr[curVertex] < g[curVertex].size (); ++ptr[curVertex]) {
int p = g[curVertex][ptr[curVertex]];
int to = e[p].to;
if (d[to] == d[v] + 1) {
int pushed = dfs (to, min (flow, e[p].cup - e[p].flow));
if (pushed) {
e[p].flow += pushed;
e[p^1].flow -= pushed;
return pushed;
}
}
}
}
int main () {
return 0;
}