CF293E Close Vertice

如果没有边数限制就是裸的淀粉质,如果有了加上一个树状数组记边数就行了。

#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
#define re register
#define ll long long
inline int gi(){int f=1,sum=0;char ch=getchar();while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}return f*sum;
}
const int N=400010;
int n,w,front[N],cnt,rt,siz[N],vis[N],tot,f[N];
struct node{int to,nxt,w;}e[N];
void Add(int u,int v,int w){e[++cnt]=(node){v,front[u],w};front[u]=cnt;}
void getroot(int u,int ff){siz[u]=1;f[u]=0;for(int i=front[u];i;i=e[i].nxt){int v=e[i].to;if(vis[v] || v==ff)continue;getroot(v,u);siz[u]+=siz[v];f[u]=max(f[u],siz[v]);}f[u]=max(f[u],tot-siz[u]);if(f[u]

转载于:https://www.cnblogs.com/mleautomaton/p/11146019.html


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部