Problem is here \(\text{Solution:}\) 首先,一眼看出这是最小割,只要叶子节点对汇点\(T\)连接流量为\(inf\)的边就可以一遍最大流搞定了. 剩下的问题在于,如何判断边的方向. 可以用\(dfs\)实现,方向由源点\(S\to T.\)而边权,注意到我们连的边是双向边,且编号连续.利用这一点我们可以在\(dfs\)里面对边进行赋值. #include<bits/stdc++.h> using namespace std; const int MAXN=5…
题目链接: Magic boy Bi Luo with his excited tree Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1037 Accepted Submission(s): 298 Problem Description Bi Luo is a magic boy, he also has a migic…
Appleman has a tree with n vertices. Some of the vertices (at least one) are colored black and other vertices are colored white. Consider a set consisting of k (0 ≤ k < n) edges of Appleman's tree. If Appleman deletes these edges from the tree, then…
题目链接: http://codeforces.com/contest/161/problem/D D. Distance in Tree time limit per test 3 secondsmemory limit per test 512 megabytes 问题描述 A tree is a connected graph that doesn't contain any cycles. The distance between two vertices of a tree is th…
Code: #include<bits/stdc++.h> #define ull unsigned long long #define MOD 1000000007 #define ll long long #define maxn 120000 using namespace std; void setIO(string s) { string in=s+".in"; string out=s+".out"; freopen(in.c_str(),&…