|Time Limit: 1000MS||Memory Limit: 65536K|
|Total Submissions: 3910||Accepted: 2347|
Bessie, feeling vindictive, decided to sabotage Farmer John’s network by cutting power to one of the barns (thereby disrupting all the connections involving that barn). When Bessie does this, it breaks the network into smaller pieces, each of which retains
full connectivity within itself. In order to be as disruptive as possible, Bessie wants to make sure that each of these pieces connects together no more than half the barns on FJ.
Please help Bessie determine all of the barns that would be suitable to disconnect.
* Lines 2..N: Each line contains two integers X and Y and represents a connection between barns X and Y.
barns, the output should be a single line containing the word "NONE".
The set of connections in the input describes a "tree": it connects all the barns together and contains no cycles.
If barn 3 or barn 8 is removed, then the remaining network will have one piece consisting of 5 barns and two pieces containing 2 barns. If any other barn is removed then at least one of the remaining pieces has size at least 6 (which is more than half of the
original number of barns, 5).
using namespace std;
#define ll long long
#define N 11000
#define mem(a,t) memset(a,t,sizeof(a))
const int inf=1000005;
void add(int u,int v)
void dfs(int u,int len,int fa)
波比源码 » poj 2378 Tree Cutting (树形dp)