编辑: cyhzg 2013-11-29

int n, m, u, v, w;

while (scanf("%d%d", &n, &m) != EOF) { for (int i = 0;

i >= 1, i++) if (det & 1) tv = fa[tv][i];

if (tu == tv) return tu;

for (int i = DEG - 1;

i >= 0;

i--) { if (fa[tu][i] == fa[tv][i]) continue;

tu = fa[tu][i];

tv = fa[tv][i];

} 图论

41 First Chapter return fa[tu][0];

} int in[maxn];

int main() { //freopen("in.txt", "r", stdin);

int t, n, u, v;

scanf("%d", &t);

while (t--) { scanf("%d", &n);

init();

memset(in, 0, sizeof(in));

for (int i = 1;

i < n;

i++) { scanf("%d%d", &u, &v);

addedge(u, v);

addedge(v, u);

in[v]++;

for (int i = 1;

i = 1, i++) if (det & 1) tv = fa[tv][i];

if (tu == tv) return tu;

for (int i = DEP - 1;

i >= 0;

i--) { if (fa[tu][i] == fa[tv][i]) continue;

tu = fa[tu][i];

tv = fa[tv][i];

} return fa[tu][0];

} int main() { //freopen("in.txt", "r", stdin);

int t, u, v, w, q;

scanf("%d", &t);

图论

44 First Chapter for (int _ = 1;

_ from = from;

this->to = to;

this->cap = cap;

this->flow = flow;

} };

struct Dinic { int n, m, s, t;

Edge edges[maxm];

int head[maxn];

int nxt[maxm];

bool vis[maxn];

int d[maxn];

int cur[maxn];

void init(int n) { this -> n = n;

memset(head, -1, sizeof(head));

m = 0;

} void AddEdge(int u, int v, int c) { edges[m] = Edge(u, v, c, 0);

nxt[m] = head[u];

head[u] = m++;

edges[m] = Edge(v, u, 0, 0);

nxt[m] = head[v];

head[v] = m++;

} bool BFS() { memset(vis, 0, sizeof(vis));

图论

64 First Chapter queueQ;

Q.push(s);

d[s] = 0;

vis[s] = 1;

while (!Q.empty()) { int x = Q.front();

Q.pop();

for (int i = head[x];

i != -1;

i = nxt[i]) { Edge& e = edges[i];

if (!vis[e.to] && e.cap > e.flow) { vis[e.to] = 1;

d[e.to] = d[x] + 1;

Q.push(e.to);

return vis[t];

} int DFS(int x, int a) { if (x == t || a == 0) return a;

int flow = 0, f;

for (int& i = cur[x];

i != -1;

i = nxt[i]) { Edge& e = edges[i];

if (d[x] +

1 == d[e.to] && (f = DFS(e.to, min(a, e.cap- e.flow += f;

edges[i^1].flow -= f;

flow += f;

a -= f;

if (a == 0) break;

return flow;

} int Maxflow(int s, int t) { this -> s = s;

this -> t = t;

图论

65 First Chapter int flow = 0;

while (BFS()) { for (int i = 0;

i < n;

i++) cur[i] = head[i];

flow += DFS(s, INF);

return flow;

} } H;

int n, m, k, id;

int g[maxn][maxn], vis[maxn][maxn], ans[maxn];

vectorG[maxn];

void init() { memset(g, 0, sizeof(g));

memset(vis, 0, sizeof(vis));

id = 0;

} void dfs(int id, int u) { vis[id][u] = 1;

G[id].push_back(u);

for (int i = 1;

i n = n;

memset(first, -1, sizeof(first));

m = 0;

} 图论

74 First Chapter void AddEdge(int u, int v, Type cap, Type cost) { edges[m] = Edge(u, v, cap, 0, cost);

next[m] = first[u];

first[u] = m++;

edges[m] = Edge(v, u, 0, 0, -cost);

next[m] = first[v];

first[v] = m++;

} bool BellmanFord(int s, int t, Type &flow, Type &cost) for (int i = 0;

下载(注:源文件不在本站服务器,都将跳转到源网站下载)
备用下载
发帖评论
相关话题
发布一个新话题