仙人掌找环板子
找出所有環中的點, 存在vector<int> v中
仙人掌要保證是雙向邊, 無重邊自環且連通. 點仙人掌和邊仙人掌都適用.
int n,cnt,dep[N],fa[N]; struct _ {int to,w;}; vector<_> g[N]; vector<int> v[N];void get(int x, int y) {if (dep[x]<dep[y]) return;++cnt;v[cnt].pb(y);for (; x!=y; x=fa[x]) v[cnt].pb(x); } void dfs(int x, int f) {fa[x]=f,dep[x]=dep[f]+1;for (_ e:g[x]) if (e.to!=f) {int y = e.to;if (dep[y]) get(x,y);else dfs(y,x);} }?
轉載于:https://www.cnblogs.com/uid001/p/10752223.html
總結
- 上一篇: MySQL查询执行的基础——查询优化处理
- 下一篇: Kubernetes之(五)快速部署应用