
tarjan
文章平均质量分 75
Ren_Ivan
衡中oier,fight for furture
展开
-
[Usaco2015 Jan]Grass Cownoisseur 图论 tarjan spfa
先缩点,对于缩点后的DAG,正反跑spfa,枚举每条边进行翻转即可 #include #include #include #include using namespace std; struct pp{ struct edge{ int u,v,w,next; }ed[200005]; int e,head[100005]; pp(){原创 2017-07-13 21:44:35 · 237 阅读 · 0 评论 -
bzoj 2730 HNOI2012 矿场搭建 tarjan
tarjan求割点, 每个点双如果不连割点,内部应建两个,连着一个割点,应建一个,连着多个,不用建 #include #include #include #include #include #define N 1500 using namespace std; int n,m,cnt,num,tot,ans1,cosmos,bo[N]; long long ans2; int dfn[N],l原创 2017-08-10 21:47:57 · 354 阅读 · 0 评论 -
bzoj2730 [HNOI2012] 矿场搭建
tarjan跑出来所有的割点 dfs搞每一个点双和几个割点相连,0个就要建两个,因为建一个的话,那个地方没了就死了,1个就要建一个,因为如果割点断了,需要内部供给,2个就不用建,任意一个断都可以从另一边过 #include #include #include #include #include #define N 1500 using namespace std; int n,m,cnt,nu原创 2017-08-20 18:08:30 · 429 阅读 · 0 评论 -
[Poi2012]Festival 差分约束+tarjan
差分约束建图,发现要在每个联通块里求最长路,600,直接O(n3) floyed #include #include #include #include #include #define N 650 #define M 100050 using namespace std; int g[N][N],n,m1,m2,f[N],ans; int e=1,head[N]; struct edge{原创 2017-08-24 16:47:56 · 362 阅读 · 0 评论