hiho week 115 register

Ended

Participants:333

Verdict:Accepted
Score:100 / 100
Submitted:2016-09-11 17:06:44

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 <bits/stdc++.h>
using namespace std;
const int N = 5005;
const int M = 100005;
const int inf = ~0u>>2;
struct eg{    
    int u, v, cap; //    
    eg(){}   
    eg(int a, int b, int c){ u = a, v = b, cap = c; }
}edg[M*4]; //
int fir[N], nex[M*4], ecnt, s, t;
void add(int a, int b, int c){    
    edg[ecnt] = eg(a, b, c);    
    nex[ecnt] = fir[a], fir[a] = ecnt++;    
    edg[ecnt] = eg(b, a, 0); //    
    nex[ecnt] = fir[b], fir[b] = ecnt++;
}
int lev[N], q[N*4], top, tail;
bool Bfs(int s, int t){    
    memset(lev, -1, sizeof(lev));    
    top = tail = 0;    
    lev[s] = 0; q[tail++] = s;   
    while( top < tail  ){        
        int u = q[top++];        
        if( u == t ) return 1;       
        for(int k = fir[u]; k != -1; k = nex[k]){ 
            int v = edg[k].v;         
            if( edg[k].cap && lev[v] == -1){         
                lev[v] = lev[u] + 1;            
                q[tail++] = v;        
                }   
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX