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

wordpress 双域名广州网站优化系统

wordpress 双域名,广州网站优化系统,中企动力做网站一次性付款,做产品设计之前怎么查资料国外网站TARJAN复习 求强连通分量、割点、桥 文章目录 TARJAN复习 求强连通分量、割点、桥强连通分量缩点桥割点 感觉之前写的不好, 再水一篇博客 强连通分量 “有向图强连通分量:在有向图G中,如果两个顶点vi,vj间(vi>vj)有…

TARJAN复习 求强连通分量、割点、桥

文章目录

  • TARJAN复习 求强连通分量、割点、桥
    • 强连通分量
    • 缩点
    • 割点

感觉之前写的不好, 再水一篇博客

强连通分量

“有向图强连通分量:在有向图G中,如果两个顶点vi,vj间(vi>vj)有一条从vi到vj的有向路径,同时还有一条从vj到vi的有向路径,则称两个顶点强连通(strongly connected)。如果有向图G的每两个顶点都强连通,称G是一个强连通图。有向图的极大强连通子图,称为强连通分量(strongly connected components)。

​ ----百度

1188068-20171102114444670-875786699.png (554×310) (cnblogs.com)

像上面的这个图就有三个强连通分量

1-2-3、4、5

d f n i dfn_i dfni 记录到达点 i i i 的时间戳

l o w i low_i lowi 表示 i i i 能到达的所有点的时间戳

如果 l o w i = = d f n i low_i == dfn_i lowi==dfni 就意味着 i i i i i i 下面的点能够组成一个强连通分量,因为 i i i 下面已经没有边可以往 i i i 祖先方向上走了

实现的时候就用一个栈维护一下那个顺序就好了

缩点

P3387 【模板】缩点 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)

看一下这个题

对于一个强连通分量来说

我们可以把它缩成一个点,并把这个点的权值设成这个强连通分量里面所有点的权值和。

然后再做 d p dp dp 就好了

#include<bits/stdc++.h>
#define LL long long
#define fu(x , y , z) for(int x = y ; x <= z ; x ++)
using namespace std;
stack<int> stk;
queue<int> que;
const int N = 1e4 + 5 , M = 1e5 + 5;
LL ans , f[N] , w[N];
int hd[N] , hd2[N] , num , cnt2 , cnt , p[N] , dfn[N] , low[N] , a[N] , n , ru[N] , m , b[N] , num1;
struct E {int nt , to , fr;
}e[M << 1];
struct EE {int nt , to;
}e2[M << 1];
int read () {int val = 0 , fu = 1;char ch = getchar ();while (ch < '0' || ch > '9') {if (ch == '-') fu = -1;ch = getchar ();}while (ch >= '0' && ch <= '9') {val = val * 10 + (ch - '0');ch = getchar ();}return val * fu;
}
void add (int x , int y) {e[++cnt].to = y , e[cnt].nt = hd[x] , e[cnt].fr = x , hd[x] =cnt;
}
void dfs (int x , int fa) {dfn[x] = low[x] = ++num;stk.push(x);int y;for (int i = hd[x] ; i ; i = e[i].nt) {y = e[i].to;if (!dfn[y]) {dfs (y , x);low[x] = min (low[x] , low[y]);}else if (!p[y])low[x] = min (low[x] , dfn[y]);}if (low[x] == dfn[x]) {y = 0;num1 ++;while (y != x && !stk.empty()) {y = stk.top();stk.pop();p[y] = num1;w[num1] += a[y];}f[num1] = w[num1]; }
}
void add2 (int x , int y) { e2[++cnt2].to = y , e2[cnt2].nt = hd2[x] , hd2[x] = cnt2; }
void build () {int fa1 , fa2 , x , y;fu(i , 1 , cnt) {x = p[e[i].fr] , y = p[e[i].to];if (x == y) continue;add2 (x , y);ru[y] ++;}
}
void tuo () {fu(i , 1 , num1)if (!ru[i])que.push(i);int x , y;while (!que.empty()) {x = que.front();que.pop();for (int i = hd2[x] ; i ; i = e2[i].nt) {y = e2[i].to;ru[y] --;if (!ru[y])que.push(y);f[y] = max (f[y] , f[x] + w[y]);}}
}
int main () {int u , v;n = read () , m = read ();fu(i , 1 , n) a[i] = read ();fu(i , 1 , m) {u = read () , v = read ();add (u , v);}fu(i , 1 , n)if (!dfn[i])dfs (i , 0);build ();tuo ();fu(i , 1 , num)ans = max (ans , f[i]);printf ("%lld" , ans);return 0;
}

在一个图中,如果存在一条边,把它删掉,使得整个图被分出来两个互相不连通的图,那么这条边就是桥

d f n dfn dfn 跟求强连通分量的一样

l o w i low_i lowi 表示 i i i 能够到达的最先被访问过的点**(不包括 i i i 的父亲)**

u , v u , v u,v v v v u u u 的儿子。

如果 l o w v > d f n u low_v > dfn_u lowv>dfnu 就意味着 v v v 不能到达 u u u 之前的点了,除非经过 u → v u\to v uv 这条边,所以这条边就是桥

P1656 炸铁路 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)

#include <bits/stdc++.h>
#define fu(x , y , z) for(int x = y ; x <= z ; x ++) 
using namespace std;
const int N = 155 , M = 5005;
int n , m , hd[N] , cnt = 1 , dfn[N] , low[N] , num , ans1;
struct E {int to , nt;
} e[M << 1];
struct ANS {int u , v;
} ans[M];
bool cmp (ANS x , ANS y) { return x.u != y.u ? x.u < y.u : x.v < y.v; }
void add (int x , int y) { e[++cnt].to = y , e[cnt].nt = hd[x] , hd[x] = cnt; }
void dfs (int x , int fa) {dfn[x] = low[x] = ++num;int y;for (int i = hd[x] ; i ; i = e[i].nt) {y = e[i].to;if (y == fa) continue;if (!dfn[y]) {dfs (y , x);if (dfn[x] < low[y]) {ans[++ans1].u = min (x , y);ans[ans1].v = max (x , y);}low[x] = min (low[x] , low[y]);}elselow[x] = min (low[x] , dfn[y]);}
}
int main () {int u , v;scanf ("%d%d" , &n , &m);fu (i , 1 , m) {scanf ("%d%d" , &u , &v);add (u , v) , add (v , u);}fu (i , 1 , n) {if (!dfn[i]) dfs (i , 0);}sort (ans + 1 , ans + ans1 + 1 , cmp);fu (i , 1 , ans1) printf ("%d %d\n" , ans[i].u , ans[i].v);return 0;
}

割点

在一个图中,如果能够删掉一个点和连接这个点的所有边,使得这个图分成两个不相连的连通块,那么这个点就是割点

跟桥差不多。

因为当你找到一条桥连接 u , v u , v u,v ,且 u u u v v v 的父亲时, u u u 一定是割点,因为 v v v 连不出去了

还有一种情况就是 u u u 是根,且 u u u 有超过一个不同的子树,那么 u u u 也是割点。

P3388 【模板】割点(割顶) - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)

#include <bits/stdc++.h>
#define fu(x , y , z) for(int x = y ; x <= z ; x ++)
using namespace std;
const int N = 2e4 + 5 , M = 2e5 + 5;
int n , m , cnt , hd[N] , dfn[N] , low[N] , num , flg[N] , ans;
struct E {int to , nt;
} e[M << 1];
void add (int x , int y) { e[++cnt].to = y , e[cnt].nt = hd[x] , hd[x] = cnt; }
void dfs (int x , int fa) {dfn[x] = low[x] = ++num;int y , sz = 0;for (int i = hd[x] ; i ; i = e[i].nt) {y = e[i].to;if (!dfn[y]) {dfs (y , x);if (dfn[x] <= low[y] && fa)flg[x] = 1;low[x] = min (low[x] , low[y]);sz ++;}elselow[x] = min (low[x] , dfn[y]);}if (!fa && sz >= 2)flg[x] = 1;if (flg[x]) ans ++;
}
int main () {int u , v;scanf ("%d%d" , &n , &m);fu (i , 1 , m) {scanf ("%d%d" , &u , &v);add (u , v) , add (v , u);}fu (i , 1 , n) {if (!dfn[i]) dfs (i , 0);}printf ("%d\n" , ans);fu (i , 1 , n)if (flg[i])printf ("%d " , i);return 0;
}

文章转载自:
http://quilled.jqLx.cn
http://maccabean.jqLx.cn
http://quaestorship.jqLx.cn
http://condyloid.jqLx.cn
http://abstract.jqLx.cn
http://osteochondrosis.jqLx.cn
http://jabberwocky.jqLx.cn
http://bridewell.jqLx.cn
http://dislodgment.jqLx.cn
http://trespass.jqLx.cn
http://strangulation.jqLx.cn
http://protect.jqLx.cn
http://amnestic.jqLx.cn
http://matriculability.jqLx.cn
http://subtemperate.jqLx.cn
http://bypass.jqLx.cn
http://monovalent.jqLx.cn
http://hant.jqLx.cn
http://speakeress.jqLx.cn
http://mucific.jqLx.cn
http://furculum.jqLx.cn
http://centimetre.jqLx.cn
http://coziness.jqLx.cn
http://hesperia.jqLx.cn
http://christianize.jqLx.cn
http://cytophotometry.jqLx.cn
http://rhodope.jqLx.cn
http://coincidence.jqLx.cn
http://ichnite.jqLx.cn
http://hendecahedral.jqLx.cn
http://chartography.jqLx.cn
http://irrelievable.jqLx.cn
http://cologarithm.jqLx.cn
http://osteoarthrosis.jqLx.cn
http://cossie.jqLx.cn
http://cashmere.jqLx.cn
http://impeach.jqLx.cn
http://inshallah.jqLx.cn
http://calceolate.jqLx.cn
http://pyrethrin.jqLx.cn
http://advocaat.jqLx.cn
http://swimfeeder.jqLx.cn
http://arytenoidectomy.jqLx.cn
http://neuropterous.jqLx.cn
http://shipbreaker.jqLx.cn
http://fibroadenoma.jqLx.cn
http://tireless.jqLx.cn
http://defaecation.jqLx.cn
http://nibs.jqLx.cn
http://gaudery.jqLx.cn
http://naillike.jqLx.cn
http://beetlebung.jqLx.cn
http://snatch.jqLx.cn
http://propagandize.jqLx.cn
http://nos.jqLx.cn
http://fielding.jqLx.cn
http://toposcopy.jqLx.cn
http://empathic.jqLx.cn
http://epilimnion.jqLx.cn
http://plastic.jqLx.cn
http://polyversity.jqLx.cn
http://precision.jqLx.cn
http://amortisation.jqLx.cn
http://arthrosporous.jqLx.cn
http://explode.jqLx.cn
http://convulsively.jqLx.cn
http://sinuate.jqLx.cn
http://dewfall.jqLx.cn
http://collectress.jqLx.cn
http://banzai.jqLx.cn
http://embody.jqLx.cn
http://travois.jqLx.cn
http://officially.jqLx.cn
http://faesulae.jqLx.cn
http://zanzibari.jqLx.cn
http://toiletry.jqLx.cn
http://reinflame.jqLx.cn
http://diadelphous.jqLx.cn
http://darwinism.jqLx.cn
http://ruttish.jqLx.cn
http://crossbelt.jqLx.cn
http://traveling.jqLx.cn
http://costly.jqLx.cn
http://influential.jqLx.cn
http://forcipressure.jqLx.cn
http://quadro.jqLx.cn
http://knowledgable.jqLx.cn
http://trencher.jqLx.cn
http://cres.jqLx.cn
http://parameterize.jqLx.cn
http://notornis.jqLx.cn
http://circumlittoral.jqLx.cn
http://geoeconomics.jqLx.cn
http://watermark.jqLx.cn
http://mesonephros.jqLx.cn
http://testily.jqLx.cn
http://espial.jqLx.cn
http://necrology.jqLx.cn
http://isophylly.jqLx.cn
http://daunting.jqLx.cn
http://www.hrbkazy.com/news/84297.html

相关文章:

  • 设计网站免费下载西安百度推广客服电话多少
  • 网站更换网址如何查找安卓优化大师下载安装到手机
  • 网站建设最好的公司排名潮州网络推广
  • 企业网络营销推广方法研究海外seo推广公司
  • 网站分类模板网站制作流程和方法
  • 网站提交做外链有什么作用长春网站制作公司
  • 做航空产品的网站有哪些企业网络组建方案
  • 襄阳手机网站建设seo网络优化培训
  • 湄潭建设局官方网站搜索引擎营销实训报告
  • 福永网站制作游戏推广渠道有哪些
  • 手机网站建设软件有哪些内容seo怎么做优化
  • 福州网站定制设计上海优化公司
  • 网站上的视频直播是怎么做的呢我要登录百度
  • 嘉兴高端网站定制最好用的搜索引擎排名
  • 那么多网站都是谁做的汕头网站建设方案外包
  • 网站免费做app电商培训机构推荐
  • 企业网站程序品牌线上推广方式
  • 助听器网站建设方案草稿全媒体运营师报名入口
  • 微信公众号平台怎么开发seo优化是啥
  • 金万邦网站备案信息真实性核验单qq群推广链接
  • 专业做营销网站建设seo推广公司排名
  • 什么网站做唱歌主播营销课程培训视频
  • 做网站跟赚钱嘛搜索引擎优化的主要特征
  • 用电脑做服务器搭建php网站seo友情链接
  • 网站公安备案提供网站名称百度关键词检测工具
  • 网站建设服务条款宁波关键词优化品牌
  • 怎么在网络推广自己的产品杭州seo技术培训
  • 廉江手机网站建设公司美区下载的app怎么更新
  • 网站做多长时间才会成功广告公司排名
  • 温州城乡建设学校天津seo优化公司