
判断正负环
笔记
幽殇默
他时若遂凌云志,敢笑黄巢不丈夫。
展开
-
904. 虫洞【判负环】
https://www.acwing.com/problem/content/906/ #include<bits/stdc++.h> using namespace std; const int N=1e5+10; int h[N],e[N],w[N],ne[N],idx; int dist[N]; int t,n,m1,m2; void add(int a,int b,int c) { e[idx]=b,w[idx]=c,ne[idx]=h[a],h[a]=idx++; } vo.原创 2021-10-15 08:34:39 · 72 阅读 · 0 评论 -
361. 观光奶牛【判断正环】
https://www.acwing.com/problem/content/363/ 求正环,可以全部取反,求负环。 正环的本质就是一个最长路,故也可以求一个最长路判断正环。 上图来自: 铅笔大佬 #include<bits/stdc++.h> using namespace std; const int N=1e4+10; int h[N],e[N],wt[N],ne[N],idx; int st[N],wf[N],cnt[N],n,m; double dist[N]; void add.原创 2021-10-15 08:34:04 · 146 阅读 · 0 评论