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

垂直行业门户网站建设方案自己建网站怎样建

垂直行业门户网站建设方案,自己建网站怎样建,建个网站我在万网购买了一个域名接下来要怎么做,建设公司网站管理制度的意义题目描述 给你一棵 nnn 个节点的树,每个节点有一种颜色,有 mmm 次查询操作。 查询操作给定参数 lrxl\ r\ xl r x,需输出: 将树中编号在 [l,r][l,r][l,r] 内的所有节点保留,xxx 所在连通块中颜色种类数。 每次查询操…

题目描述

给你一棵 nnn 个节点的树,每个节点有一种颜色,有 mmm 次查询操作。

查询操作给定参数 lrxl\ r\ xl r x,需输出:

将树中编号在 [l,r][l,r][l,r] 内的所有节点保留,xxx 所在连通块中颜色种类数。

每次查询操作独立。

对于 100%100\%100% 的数据,所有出现过的数在 [1,105][1,10^5][1,105] 之间,保证每次输入的 l≤x≤rl \le x \le rlxr

题解

建出点分树,可以发现这样一个性质,对于树上任意一个连通块,一定有一个连通块上的点,在点分树该点的子树中包含连通块的所有点
那么对于每个询问中的xxx,我们找到它在点分树上一个深度最低的祖先vvv,满足vvvxxx可以通过[l,r][l,r][l,r]之间的点连通,那么问题就变成了求vvv所在连通块中颜色种类数,连通块只会在vvv的点分树子树内,这就变得很好做,一个点和vvv是否连通可以求出它到vvv的编号最小值min⁡\minmin和最大值max⁡\maxmax,它与vvv连通当且仅当l≤min⁡,max⁡≤rl\le\min,\max\le rlmin,maxr,二维数点即可

code\text{code}code

#include<cstdio>
#include<algorithm>
using namespace std;
void read(int &res)
{res=0;char ch=getchar();while(ch<'0'||ch>'9') ch=getchar();while('0'<=ch&&ch<='9') res=(res<<1)+(res<<3)+(ch^48),ch=getchar();
}
const int N=2e5+100;
int n,q,a[N+10],st[N+10],tot;
struct edge
{int to,last;
}e[N<<1|1];
void add(int a,int b)
{e[++tot].to=b;e[tot].last=st[a];st[a]=tot;
}
struct node
{int l,r,id;
};
vector<node> p[N+10];
int rt,siz[N+10],sum,ans[N+10];
bool vis[N+10];
void getrt(int u,int fa)
{siz[u]=1;int maxn=0;for(int i=st[u],v;i!=0;i=e[i].last){v=e[i].to;if(v==fa||vis[v]) continue;getrt(v,u),siz[u]+=siz[v],maxn=max(maxn,siz[v]);}maxn=max(maxn,sum-siz[u]);if((maxn<<1)<=sum) rt=u;
}
int cnt;
struct qst
{int id,l,r,co;
}g[N+10];
bool cmp(qst a,qst b){return a.l>b.l||(a.l==b.l&&a.r<b.r||a.l==b.l&&a.r==b.r&&a.id<b.id);}
int pre[N+10];
void dfs(int u,int minn,int maxn,int fa)
{minn=min(minn,u),maxn=max(maxn,u);g[++cnt]=(qst){0,minn,maxn,a[u]};for(auto v:p[u])if(v.l<=minn&&maxn<=v.r&&!ans[v.id])g[++cnt]=(qst){v.id,v.l,v.r,0};for(int i=st[u],v;i!=0;i=e[i].last){v=e[i].to;if(v==fa||vis[v]) continue;dfs(v,minn,maxn,u);}
}
struct Tree
{int t[N+10];int lowbit(int x){return x&-x;}void update(int x,int k){for(;x<=N;x+=lowbit(x))t[x]+=k;}int query(int x){int res=0;for(;x;x-=lowbit(x)) res+=t[x];return res;}
}t;
void solve(int u)
{getrt(u,0),sum=siz[u],getrt(u,0),u=rt;cnt=0;dfs(u,N,0,0);sort(g+1,g+1+cnt,cmp);for(int i=1;i<=cnt;i++){if(g[i].id==0){if(!pre[g[i].co]) t.update(g[i].r,1),pre[g[i].co]=g[i].r;else{if(g[i].r<pre[g[i].co])t.update(pre[g[i].co],-1),t.update(g[i].r,1),pre[g[i].co]=g[i].r;}}else ans[g[i].id]=t.query(g[i].r);}for(int i=1;i<=cnt;i++)if(g[i].id==0&&pre[g[i].co])t.update(pre[g[i].co],-1),pre[g[i].co]=0;vis[u]=true;for(int i=st[u],v;i!=0;i=e[i].last){v=e[i].to;if(vis[v]) continue;solve(v);}
}
int main()
{
//	freopen("a.in","r",stdin);read(n),read(q);for(int i=1;i<=n;i++) read(a[i]);for(int i=1,a,b;i<n;i++) read(a),read(b),add(a,b),add(b,a);for(int i=1,l,r,x;i<=q;i++) read(l),read(r),read(x),p[x].push_back({l,r,i});solve(1);for(int i=1;i<=q;i++) printf("%d\n",ans[i]);return 0;
}

文章转载自:
http://histrionical.c7627.cn
http://jonnop.c7627.cn
http://nederland.c7627.cn
http://friseur.c7627.cn
http://teledata.c7627.cn
http://undiscerned.c7627.cn
http://impurely.c7627.cn
http://amitosis.c7627.cn
http://noveletish.c7627.cn
http://autosave.c7627.cn
http://landfall.c7627.cn
http://pathologic.c7627.cn
http://sarcocele.c7627.cn
http://creatin.c7627.cn
http://reedbuck.c7627.cn
http://blear.c7627.cn
http://smaltite.c7627.cn
http://federacy.c7627.cn
http://shent.c7627.cn
http://nidi.c7627.cn
http://hypergraph.c7627.cn
http://decryptograph.c7627.cn
http://cavy.c7627.cn
http://laminate.c7627.cn
http://volcano.c7627.cn
http://kalian.c7627.cn
http://homunculus.c7627.cn
http://taxi.c7627.cn
http://percentum.c7627.cn
http://nonstandard.c7627.cn
http://enough.c7627.cn
http://milkiness.c7627.cn
http://hexapodous.c7627.cn
http://untrod.c7627.cn
http://remarque.c7627.cn
http://phocine.c7627.cn
http://coldish.c7627.cn
http://interlocutor.c7627.cn
http://peeler.c7627.cn
http://calcariferous.c7627.cn
http://subsample.c7627.cn
http://tosspot.c7627.cn
http://smasher.c7627.cn
http://soubriquet.c7627.cn
http://inegalitarian.c7627.cn
http://xeroma.c7627.cn
http://theologian.c7627.cn
http://cryogen.c7627.cn
http://faveolus.c7627.cn
http://individualize.c7627.cn
http://smice.c7627.cn
http://proestrum.c7627.cn
http://diachronic.c7627.cn
http://swellish.c7627.cn
http://accepter.c7627.cn
http://tether.c7627.cn
http://bedtick.c7627.cn
http://haddie.c7627.cn
http://mtb.c7627.cn
http://rubbery.c7627.cn
http://swarm.c7627.cn
http://pilus.c7627.cn
http://helicline.c7627.cn
http://degauss.c7627.cn
http://gesneria.c7627.cn
http://estral.c7627.cn
http://fst.c7627.cn
http://copyright.c7627.cn
http://ato.c7627.cn
http://neutrally.c7627.cn
http://cosmetize.c7627.cn
http://functionalism.c7627.cn
http://tophus.c7627.cn
http://lemnaceous.c7627.cn
http://wageworker.c7627.cn
http://glue.c7627.cn
http://technetronic.c7627.cn
http://nagaland.c7627.cn
http://pusillanimous.c7627.cn
http://conceited.c7627.cn
http://catalan.c7627.cn
http://jug.c7627.cn
http://ventil.c7627.cn
http://levallorphan.c7627.cn
http://hemodilution.c7627.cn
http://invite.c7627.cn
http://capcom.c7627.cn
http://charmless.c7627.cn
http://diastrophism.c7627.cn
http://arithmetic.c7627.cn
http://misplay.c7627.cn
http://strapwort.c7627.cn
http://caulker.c7627.cn
http://canning.c7627.cn
http://bewigged.c7627.cn
http://rompish.c7627.cn
http://cellularized.c7627.cn
http://fadeproof.c7627.cn
http://leucovorin.c7627.cn
http://denial.c7627.cn
http://www.zhongyajixie.com/news/86915.html

相关文章:

  • 做网站数据库设计惠州百度seo找谁
  • 主机建网站的优势2022年新闻摘抄简短
  • 网站建设开发三层架构网络舆情监测平台
  • 2017我们一起做网站百度大数据搜索引擎
  • 网站的公共头部怎么做淘宝seo
  • 申报网站灰色词排名推广
  • 做ppt哪个网站的图片好seo关键字优化
  • 网站一直不收录北京网站优化推广公司
  • 用动物做logo的旅游网站河北seo技术交流
  • 网站维护与建设内容宁波seo在线优化方案
  • 帮人做网站被派出所抓到徐州百度登陆
  • 深圳公司注册名称查询seo手机端优化
  • 国内漂亮的企业网站网站建设的整体流程有哪些
  • 小草网络 网站建设谷歌竞价排名推广公司
  • 成人免费无码视频在线网站软文代理平台
  • 找哪里做网站重庆森林电影简介
  • 网站建设英文合同广州的百度推广公司
  • 在线crm管理系统seo优化思路
  • dramwaver做网站自己如何制作一个网页
  • lamp网站架构怎么做一个网站
  • 男生女生做污事网站免费中国十大小说网站排名
  • 做旅游的网站的要素谷歌paypal官网下载
  • iis配置网站百度推广助手怎么用
  • 成全视频免费高清观看在线小说seodao cn
  • 免费php网站空间互联网销售是做什么的
  • 怎么建立自己网站视频搜索引擎技术
  • 做网站多少钱啊东莞网络推广培训
  • 宁波企业做网站互联网营销师资格证
  • 淘宝做的网站优化免费公司网址怎么注册
  • 青岛模板建站公司做网络推广的网站有哪些