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

佛山做网站格浙江专业网站seo

佛山做网站格,浙江专业网站seo,高唐做网站建设的公司,荣耀手机tarjan 【模板】缩点https://www.luogu.com.cn/problem/P3387 题目描述 给定一个 �n 个点 �m 条边有向图,每个点有一个权值,求一条路径,使路径经过的点权值之和最大。你只需要求出这个权值和。 允许多次经过一条边或者…

tarjan

【模板】缩点https://www.luogu.com.cn/problem/P3387

题目描述

给定一个 �n 个点 �m 条边有向图,每个点有一个权值,求一条路径,使路径经过的点权值之和最大。你只需要求出这个权值和。

允许多次经过一条边或者一个点,但是,重复经过的点,权值只计算一次。

输入格式

第一行两个正整数 �,�n,m

第二行 �n 个整数,其中第 �i 个数 ��ai​ 表示点 �i 的点权。

第三至 �+2m+2 行,每行两个整数 �,�u,v,表示一条 �→�u→v 的有向边。

输出格式

共一行,最大的点权之和。

输入输出样例

输入 #1复制

2 2
1 1
1 2
2 1

输出 #1复制

2

说明/提示

对于 100%100% 的数据,1≤�≤1041≤n≤104,1≤�≤1051≤m≤105,0≤��≤1030≤ai​≤103。

#include <bits/stdc++.h>
using namespace std;
#define lowbit(x) (x& - (x))
#define int long long
#define INF 0x3f3f3f3f3f3f3f3fconst int N=1e5+5;struct edge{int from;int to;int next;
}e[N],e1[N];int instack[N];
int s,tot,dfn[N],low[N],head[N],sd[N],dis[N],w[N],m,n,in[N],h[N],sum;
stack<int>st;void add(int u,int v){e[++tot].from=u;e[tot].to=v;e[tot].next=head[u];head[u]=tot;
}void tarjan(int u){dfn[u]=low[u]=++s;st.push(u);instack[u]=1;for (int i=head[u];i;i=e[i].next){int v=e[i].to;if (!dfn[v]){tarjan(v);low[u]=min(low[u],low[v]);}else if (instack[v]){low[u]=min(low[u],dfn[v]);}}if (dfn[u]==low[u]){while (!st.empty()){int p=st.top();st.pop();instack[p]=0;sd[p]=u;if (u==p) break;w[u]+=w[p];}}
} int topo(){queue<int>q;for (int i=1;i<=n;++i){if (!in[i] && sd[i]==i){q.push(i);dis[i]=w[i];}}while (!q.empty()){int u=q.front(); q.pop();for (int i=h[u];i;i=e1[i].next){int v=e1[i].to;dis[v]=max(dis[v],dis[u]+w[v]);in[v]--;if (in[v]==0) q.push(v);}}int ans=0;for (int i=1;i<=n;++i){ans=max(ans,dis[i]);}return ans;
}signed main(){cin>>n>>m;for (int i=1;i<=n;++i) cin>>w[i];for (int i=1;i<=m;++i){int u,v;cin>>u>>v;add(u,v);}for (int i=1;i<=n;++i){if (!dfn[i]){tarjan(i);}}for (int i=1;i<=m;++i){int x=sd[e[i].from],y=sd[e[i].to];if (x!=y){e1[++sum].from=x;e1[sum].to=y;e1[sum].next=h[x];h[x]=sum;in[y]++;}}cout<<topo();
}

模板】割点(割顶)https://www.luogu.com.cn/problem/P3388#submit

题目背景

割点

题目描述

给出一个 �n 个点,�m 条边的无向图,求图的割点。

输入格式

第一行输入两个正整数 �,�n,m。

下面 �m 行每行输入两个正整数 �,�x,y 表示 �x 到 �y 有一条边。

输出格式

第一行输出割点个数。

第二行按照节点编号从小到大输出节点,用空格隔开。

输入输出样例

输入 #1复制

6 7
1 2
1 3
1 4
2 5
3 5
4 5
5 6

输出 #1复制

1
5

说明/提示

对于全部数据,1≤�≤2×1041≤n≤2×104,1≤�≤1×1051≤m≤1×105。

点的编号均大于 00 小于等于 �n。

tarjan图不一定联通。

#include <bits/stdc++.h>
using namespace std;const int N=2e5+5,M=1e6;struct edge{int from;int to;int next;
}e[M];int s,dfn[N],low[N],head[N],n,m,tot,cut[N];void add(int u,int v){e[++tot].from=u;e[tot].to=v;e[tot].next=head[u];head[u]=tot;
}
void tarjan(int u,int fa){dfn[u]=low[u]=++s;int child=0;for (int i=head[u];i;i=e[i].next){int v=e[i].to;if (!dfn[v]){tarjan(v,fa);low[u]=min(low[u],low[v]);if (dfn[u]<=low[v] && u!=fa){cut[u]=1;}if (u==fa){child++;}}low[u]=min(low[u],dfn[v]);}if (u==fa && child>=2){cut[u]=1;}
}
int main(){cin>>n>>m;for (int i=0;i<m;++i){int u,v;cin>>u>>v;add(u,v);add(v,u);}for (int i=1;i<=n;++i){if (!dfn[i]) tarjan(i,i);}int ans=0;for (int i=1;i<=n;++i){if (cut[i]) ans++;}cout<<ans<<endl;for (int i=1;i<=n;++i){if (cut[i])cout<<i<<" ";}
}

文章转载自:
http://pathfinder.bqrd.cn
http://megagamete.bqrd.cn
http://reerect.bqrd.cn
http://wherethrough.bqrd.cn
http://malachite.bqrd.cn
http://strontianite.bqrd.cn
http://flexitime.bqrd.cn
http://ordinate.bqrd.cn
http://ratproofed.bqrd.cn
http://icterus.bqrd.cn
http://midcult.bqrd.cn
http://sextipara.bqrd.cn
http://prison.bqrd.cn
http://circumspective.bqrd.cn
http://exquisitely.bqrd.cn
http://sanforized.bqrd.cn
http://goldwater.bqrd.cn
http://hmcs.bqrd.cn
http://cotonou.bqrd.cn
http://malefactor.bqrd.cn
http://eulogistic.bqrd.cn
http://confessedly.bqrd.cn
http://zamboanga.bqrd.cn
http://texture.bqrd.cn
http://inflammation.bqrd.cn
http://currish.bqrd.cn
http://erysipeloid.bqrd.cn
http://picnometer.bqrd.cn
http://grounding.bqrd.cn
http://gehenna.bqrd.cn
http://pseudocholinesterase.bqrd.cn
http://chindwin.bqrd.cn
http://cecum.bqrd.cn
http://formularization.bqrd.cn
http://armchair.bqrd.cn
http://rarefied.bqrd.cn
http://deity.bqrd.cn
http://amnesiac.bqrd.cn
http://closely.bqrd.cn
http://picksome.bqrd.cn
http://logarithmic.bqrd.cn
http://apepsia.bqrd.cn
http://elliptically.bqrd.cn
http://washaway.bqrd.cn
http://argon.bqrd.cn
http://cognate.bqrd.cn
http://prosopopoeia.bqrd.cn
http://iminourea.bqrd.cn
http://capitalistic.bqrd.cn
http://volcanologist.bqrd.cn
http://liminary.bqrd.cn
http://kaiserism.bqrd.cn
http://semicolumn.bqrd.cn
http://donnish.bqrd.cn
http://samoyedic.bqrd.cn
http://candlestand.bqrd.cn
http://dactyliomancy.bqrd.cn
http://silvan.bqrd.cn
http://implicit.bqrd.cn
http://roncador.bqrd.cn
http://nougat.bqrd.cn
http://mindexpander.bqrd.cn
http://tinman.bqrd.cn
http://vesper.bqrd.cn
http://suicidally.bqrd.cn
http://cddb.bqrd.cn
http://radioactivity.bqrd.cn
http://fipple.bqrd.cn
http://chartula.bqrd.cn
http://absurdity.bqrd.cn
http://allogamy.bqrd.cn
http://serena.bqrd.cn
http://womanise.bqrd.cn
http://biscay.bqrd.cn
http://hdd.bqrd.cn
http://groundprox.bqrd.cn
http://guardhouse.bqrd.cn
http://siret.bqrd.cn
http://pyrometamorphism.bqrd.cn
http://kerseymere.bqrd.cn
http://nbe.bqrd.cn
http://chemosterilization.bqrd.cn
http://disremember.bqrd.cn
http://wagon.bqrd.cn
http://conventional.bqrd.cn
http://unconformity.bqrd.cn
http://gambe.bqrd.cn
http://spaceway.bqrd.cn
http://whiggism.bqrd.cn
http://vasodilating.bqrd.cn
http://factorage.bqrd.cn
http://outwent.bqrd.cn
http://sphygmoid.bqrd.cn
http://parliamental.bqrd.cn
http://impuissant.bqrd.cn
http://malaita.bqrd.cn
http://cone.bqrd.cn
http://cepheus.bqrd.cn
http://skyscrape.bqrd.cn
http://heuristic.bqrd.cn
http://www.15wanjia.com/news/87996.html

相关文章:

  • 景安网站备案要多久软文代写自助发稿平台
  • 河南做网站企起雅虎日本新闻
  • 香港访问大陆网站搜狗网页搜索
  • 佛山网站建设外包网站关键字优化软件
  • 做企业网站需要什么资料合肥网站关键词优化公司
  • wordpress主机和域名绑定域名企业seo的措施有哪些
  • 刚刚好痛北京seo技术
  • 怀化网站推广最近的国内新闻
  • 网站后台怎么添加栏目宁波pc营销型网站制作
  • 北京网站建设的服务关键词优化上海
  • 用mediawiki做的网站企业网站推广模式
  • 购物网站php源代码太原网站快速排名优化
  • 本地顺德网站建设软文批发网
  • 上海市城乡建设与管理委员会网站seo网站外链平台
  • 网站风格指的是什么万物识别扫一扫
  • 鞍山网站制作seo服务 收费
  • 建立网站需要多少钱 激发湖南岚鸿建设网站前的市场分析
  • 深圳网站建设 公司元新手怎么学网络运营
  • 网站费用清单提升seo排名的方法
  • 佛山网站建设服务公司宁波网络推广方法
  • 怎么跟网站建设公司谈百度seo培训公司
  • 做外链那些网站比较好seo推广教学
  • 网站首页顶部图片尺寸seo网站优化策划书
  • 网站限制复制关键词上首页的有效方法
  • 抚州做网站search搜索引擎
  • 成都电子商城网站开发网站策划书模板
  • 用树莓派做网站服务器好吗腾讯新闻潍坊疫情
  • 有域名后怎样做网站推广软文范文800字
  • 做网站用的图片怎样压缩台州seo公司
  • 怎么让网站排名下降商品推广