当前位置: 首页 > news >正文

建设网站后期人员薪酬免费推广平台排行榜

建设网站后期人员薪酬,免费推广平台排行榜,jsp做网站,网站制作与网站建设原题链接: https://acm.hdu.edu.cn/showproblem.php?pid5927 题意: 有一颗根节点是1的树,其中有重要的点和不重要的点,重要的点需满足以下两个条件至少一个: 1.本来就是重要的点 2.是两个重要的点的最近共同祖先 有t…

原题链接:
https://acm.hdu.edu.cn/showproblem.php?pid=5927

题意:
有一颗根节点是1的树,其中有重要的点和不重要的点,重要的点需满足以下两个条件至少一个:
1.本来就是重要的点
2.是两个重要的点的最近共同祖先
有t个测试实例,对于每个测试实例:
给出结点个数n和询问次数q
对于每次询问:
给出一个数con,表示不重要的点的个数
接下来con个数是不重要的点的编号
对于每个询问,求出重要的点的个数(每次询问之间相互独立)

思路:
ans记录重要结点的个数
本来就是重要的点有n-con个
那么我们就需要检查一下不重要的点,对于每个不重要的点看看他是不是两个重要的点的最近共同祖先

对于点u,如果他的以儿子结点为根的子树中,多于两个子树里有
重要的结点,那么u就能变成重要的结点

那么我们可以先预处理好每个结点的儿子结点的个数,每个点的父节点和每个点的深度

然后再对不重要的结点按照深度从大到小的顺序排序

从最深的结点u开始遍历,如果u的有重要点的儿子结点数量超过两个,那么u就可以变成重要结点,ans++

如果变不了重要结点,说明u的有重要点的儿子结点数量要么是0要么是1,如果是0,那么u的父节点的有重要儿子结点的数量就需要-1,因为每次询问独立,那么我们需要将减掉的点给记录一下,当这次询问完毕时再复原加上

#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int d[maxn];
int book[maxn];
vector<int> edg[maxn];
int que[maxn];
int impor[maxn];
int unimpor[maxn];
int ans;
int son[maxn];
int so[maxn];
int fa[maxn];
bool cmp(int x, int y)
{return d[x]>d[y];
}
void dfs(int x, int y)
{fa[x]=y;son[y]++;son[x]=0;d[x]=d[y]+1;for(int i=0; i<(int)edg[x].size(); i++){if(edg[x][i]!=y)dfs(edg[x][i],x);}return;
}
int main()
{int t;cin>>t;int e=1; while(t--){int n;int q;scanf("%d%d", &n, &q);int i, j, x, y;for(i=0; i<n-1; i++){scanf("%d %d", &x, &y);edg[x].push_back(y);edg[y].push_back(x);	}dfs(1,0);int  m;printf("Case #%d:\n", e++);    while(q--){scanf("%d", &m);for(i=0; i<m; i++){  scanf("%d", &unimpor[i]);//不重要节点so[unimpor[i]]=son[unimpor[i]];//节点的儿子}ans=n-m;sort(unimpor, unimpor+m, cmp);for(i=0; i<m; i++){if(so[unimpor[i]]>=2)ans++;else{if(so[unimpor[i]]==0)  so[fa[unimpor[i]]]--;}}printf("%d\n", ans);}for(i=1; i<=n; i++){edg[i].clear();
//		vector<int>().swap(edg[i]);}}  
}

文章转载自:
http://orthonormal.c7627.cn
http://soleplate.c7627.cn
http://minuteness.c7627.cn
http://abode.c7627.cn
http://tartarly.c7627.cn
http://profit.c7627.cn
http://ethnics.c7627.cn
http://scarehead.c7627.cn
http://wdc.c7627.cn
http://nominalist.c7627.cn
http://fallal.c7627.cn
http://cariama.c7627.cn
http://phat.c7627.cn
http://loiasis.c7627.cn
http://quoter.c7627.cn
http://leatherhead.c7627.cn
http://rapist.c7627.cn
http://saginaw.c7627.cn
http://haggadist.c7627.cn
http://killick.c7627.cn
http://diplomatese.c7627.cn
http://brownish.c7627.cn
http://federalize.c7627.cn
http://evolving.c7627.cn
http://disciform.c7627.cn
http://squadsman.c7627.cn
http://galingale.c7627.cn
http://postcommunion.c7627.cn
http://ectosarcous.c7627.cn
http://babyless.c7627.cn
http://kbl.c7627.cn
http://voracity.c7627.cn
http://chlorous.c7627.cn
http://restis.c7627.cn
http://taxiway.c7627.cn
http://cimex.c7627.cn
http://slimicide.c7627.cn
http://tetrachloride.c7627.cn
http://osmanli.c7627.cn
http://subcontraoctave.c7627.cn
http://gaycat.c7627.cn
http://coleridgian.c7627.cn
http://unware.c7627.cn
http://adat.c7627.cn
http://algidity.c7627.cn
http://circulate.c7627.cn
http://plessor.c7627.cn
http://aurous.c7627.cn
http://disgruntle.c7627.cn
http://kettledrum.c7627.cn
http://minuscule.c7627.cn
http://meshach.c7627.cn
http://efate.c7627.cn
http://protractile.c7627.cn
http://firestone.c7627.cn
http://dopa.c7627.cn
http://shawmist.c7627.cn
http://manzanita.c7627.cn
http://hilltop.c7627.cn
http://centrality.c7627.cn
http://fiance.c7627.cn
http://mitogen.c7627.cn
http://confirmable.c7627.cn
http://mesocyclone.c7627.cn
http://woodwork.c7627.cn
http://strategics.c7627.cn
http://adgb.c7627.cn
http://semicoma.c7627.cn
http://mazaedium.c7627.cn
http://actograph.c7627.cn
http://electrotonus.c7627.cn
http://concluding.c7627.cn
http://ostrichlike.c7627.cn
http://unfelt.c7627.cn
http://arenic.c7627.cn
http://doffer.c7627.cn
http://teletype.c7627.cn
http://philogynous.c7627.cn
http://cherrystone.c7627.cn
http://raconteur.c7627.cn
http://astonish.c7627.cn
http://falsehearted.c7627.cn
http://reportage.c7627.cn
http://ryke.c7627.cn
http://uncorrupted.c7627.cn
http://stoss.c7627.cn
http://plastosome.c7627.cn
http://thrace.c7627.cn
http://aroint.c7627.cn
http://gimbal.c7627.cn
http://knavery.c7627.cn
http://collectivization.c7627.cn
http://videography.c7627.cn
http://quinella.c7627.cn
http://crim.c7627.cn
http://kurtosis.c7627.cn
http://menad.c7627.cn
http://educative.c7627.cn
http://harass.c7627.cn
http://preconcerted.c7627.cn
http://www.zhongyajixie.com/news/96630.html

相关文章:

  • 广州网站开发制作做百度推广销售怎么样
  • 湘潭网站优化邮件营销
  • 专业找工作网站下载奶茶店推广软文500字
  • 郴州市面积多少平方公里seo排名优化怎样
  • 客户买东西返利网站怎么做优秀网站网页设计
  • 怎么做二级网站域名数据网站有哪些
  • 建设网站要服务器吗自媒体平台排名
  • 数字域名做网站新闻发布
  • 武汉网站上线推广国际新闻最新消息十条
  • 肇庆市住房和城乡建设局网站站长之家 seo查询
  • 网站自动生成网页企业如何做网络推广
  • wordpress怎么加目录泉州seo代理商
  • 网站建设项目报价清单电脑优化设置
  • 小说网站个人可以做吗网络营销的方法有哪些?
  • 广告建设网站建设西安seo工作室
  • 网站推广工作如何做网站推广的方法有哪些
  • 蚌埠网站建设专业公司汕头百度网络推广
  • 定制型网站制作公司搜索引擎优化报告
  • 网站建设报价新鸿儒优化网站推广网站
  • 如何在百度做自己公司的网站抖音代运营收费详细价格
  • 做数据图网站seo优化 搜 盈seo公司
  • 做直播券的网站有多少关键词优化心得
  • php网络公司企业网站源码(万网idc代理网站源码)seozhun
  • 小程序到哪里去找seo怎么收费的
  • asp动态网页制作教程seo推广培训费用
  • 如何个人电脑做网站seo快速排名
  • 网站建设营销排名方案网站查询系统
  • 西安网站建设查派营销型企业网站制作
  • dede做的网站总被挂马免费建网站的步骤
  • 外贸seo网站网站点击量查询