【边双联通分量】hihoCoder#1184 连通性二·边的双连通分量
来源:互联网 发布:淘宝双11报名 编辑:程序博客网 时间:2024/06/05 23:46
【边双联通分量】hihoCoder#1184 连通性二·边的双连通分量
题面在这里
其实就是边双的裸题
示例程序:
//hihocoder 1184#include<cstdio>#include<cstring>#include<algorithm>#define cl(x,y) memset(x,y,sizeof(x))using namespace std;inline char nc(){ static char buf[100000],*p1=buf,*p2=buf; return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;}inline int red(){ int res=0,f=1;char ch=nc(); while (ch<'0'||'9'<ch) {if (ch=='-') f=-f;ch=nc();} while ('0'<=ch&&ch<='9') res=(res<<3)+(res<<1)+ch-48,ch=nc(); return res*f;}const int maxn=20005,maxe=200005;int n,e;int tot,son[maxe],lnk[maxn],nxt[maxe];inline void add(int x,int y){ son[++tot]=y;nxt[tot]=lnk[x];lnk[x]=tot;}int times,in[maxn],low[maxn];bool isb[maxe];void tarjan(int x,int fa){ low[x]=in[x]=++times; for (int j=lnk[x];j;j=nxt[j]) if (!in[son[j]]){ tarjan(son[j],x); low[x]=min(low[x],low[son[j]]); if (low[son[j]]>dfn[x]) isb[j]=isb[j^1]=1; }else if (son[j]!=fa) low[x]=min(low[x],in[son[j]]);}int BCC,bcc[maxn],Min[maxn];void bl(int x){ bcc[x]=BCC;Min[BCC]=min(Min[BCC],x); for (int j=lnk[x];j;j=nxt[j]) if (!isb[j]&&!bcc[son[j]]) bl(son[j]);}int main(){ n=red(),e=red();tot=1; for (int i=1,x,y;i<=e;i++) x=red(),y=red(),add(x,y),add(y,x); for (int i=1;i<=n;i++) if (!in[i]) tarjan(i,0); cl(Min,63); for (int i=1;i<=n;i++) if (!bcc[i]) BCC++,bl(i); printf("%d\n",BCC); for (int i=1;i<=n;i++) printf("%d ",Min[bcc[i]]); return 0;}
阅读全文
1 0
- 【边双联通分量】hihoCoder#1184 连通性二·边的双连通分量
- hihocoder 1184 : 连通性二·边的双连通分量
- hihocoder #1184 : 连通性二·边的双连通分量
- HIHO #1184 : 连通性二·边的双连通分量
- hiho一下 连通性二·边的双连通分量
- hiho 53 连通性二·边的双连通分量
- hihoCoder_#1184_连通性二·边的双连通分量
- [边双]hihocoder 1184——边的双连通分量
- BZOJ 3590 Quare [状压DP][边双连通分量][点双联通分量]
- [hihoCoder 1190] 连通性·四:点-双连通分量
- hiho一下 连通性·四 点的双连通分量
- 边双连通分量
- POJ 3352 边的双连通分量
- 边的双连通分量问题
- 点-双连通分量&边-双连通分量复习笔记
- 边双连通分量模版
- HDU4738【边双连通分量】
- 边双连通分量模板
- video pixel networks阅读笔记
- Gtktreeview链表和树型存储结构
- 用AXIS2发布WebService的方法 使用eclipse插件生成服务端和客户端
- 每周LeetCode算法题(八): 题目: 221. Maximal Square & 85. Maximal Rectangle
- Python3 GUI中Tkinter
- 【边双联通分量】hihoCoder#1184 连通性二·边的双连通分量
- 07-面向对象(多态-类型判断-instanceof)1 2 3 4 5
- Convolutional neural network transfer for automated glaucoma identification论文理解
- 一只爬虫带你看世界【7】
- MyEclipse忽略单个文件的错误提示操作
- luogu1624 单词缩写
- java中对类中的成员变量和成员方法的封装及private关键字
- 常见功能--下拉刷新、上拉加载更多效果实现
- 【语言转换】matlab prctile方法IDL实现