hiho week 119 register

Ended

Participants:2176

Verdict:Accepted
Score:100 / 100
Submitted:2016-10-09 07:28:52

Lang:G++

Edit
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
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 405;
const int maxm = 41000;
const int inf = 0x3fffffff;
template <typename T, int N, int M>
class Dinic
{
    int m, source, sink, range1, range2;
    T inf;
    int head[M], next[M], d[N], q[N], cur[N];
    struct edge { int v; T c; } e[M];
    bool bfs()
    {
        int i, x, ql(0), qr(0);
        memset(d, -1, sizeof d);
        d[q[0] = source] = 0;
        while (ql <= qr)
        {
            x = q[ql++];
            for (i = head[x]; i; i = next[i])
                if (e[i].c && d[e[i].v] == -1)
                {
                    q[++qr] = e[i].v;
                    d[e[i].v] = d[x] + 1;
                    if (e[i].v == sink) return true;
                }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX