bzoj 1123 BLO
来源:互联网 发布:美国滑板鞋牌子 知乎 编辑:程序博客网 时间:2024/04/29 22:25
1123: [POI2008]BLO
Description
Byteotia城市有n个 towns m条双向roads. 每条 road 连接 两个不同的 towns ,没有重复的road. 所有towns连通。
Input
输入n<=100000 m<=500000及m条边
Output
输出n个数,代表如果把第i个点去掉,将有多少对点不能互通。
Sample Input
5 5
1 2
2 3
1 3
3 4
4 5
Sample Output
8
8
16
14
8
题解:
其实就是个tarjan求点双。
点双并不用实际求出来,只是在搜索树中传上去,遇到割点求一下即可。
注意(x,y)和(y,x)是不同对点。
附上代码:
#include<iostream>#include<cstdlib>#include<cstring>#include<cstdio>#include<algorithm>#include<cmath>using namespace std;#define int long long#define mmin(a,b) (a<b?a:b)struct tree{ int u,v,next;}l[1001000];int n,m,lian[101000],e,ans[101000];int dfn[101000],low[101000],num,size[101000];void bian(int,int);void tar(int);signed main(){// freopen("in.txt","r",stdin); scanf("%lld%lld",&n,&m); for(int i=1;i<=m;i++) { int x,y; scanf("%lld%lld",&x,&y); bian(x,y); bian(y,x); } tar(1); for(int i=1;i<=n;i++) printf("%lld\n",ans[i]+2*n-2);// while(1); return 0;}void bian(int x,int y){ e++; l[e].u=x; l[e].v=y; l[e].next=lian[x]; lian[x]=e;}void tar(int x){ dfn[x]=low[x]=++num; size[x]=1; int zz=0; for(int i=lian[x];i;i=l[i].next) { int v=l[i].v; if(dfn[v]==0) { tar(v); size[x]+=size[v]; low[x]=mmin(low[x],low[v]); if(dfn[x]<=low[v]) { ans[x]+=zz*size[v]*2ll; zz+=size[v]; } } else low[x]=mmin(dfn[v],low[x]); } ans[x]+=zz*(n-zz-1)*2ll;}
阅读全文
0 0
- BZOJ 1123: [POI2008]BLO
- bzoj-1123 BLO
- bzoj 1123 [POI2008]BLO
- bzoj 1123 BLO
- bzoj 1123: [POI2008]BLO
- 【tarjan】【bzoj 1123】: [POI2008]BLO
- BZOJ 1123 POI2008 BLO Tarjan+树形DP
- BZOJ 1123: [POI2008]BLO tarjan求割点
- [BZOJ]1123 [POI2008]BLO 割点
- BZOJ 1123: [POI2008]BLO 图的连通性
- BZOJ 1123 [POI2008]BLO 点双连通分量
- BZOJ 1123: [POI2008]BLO 点双联通,Tarjan求割点
- bzoj 1123: [POI2008]BLO (tarjan求点双+树形DP)
- BZOJ 1123 POI 2008 BLO题解 Tarjan求割点+乘法原理
- BZOJ 1123: [POI2008]BLO [割点][乘法原理]
- 【BZOJ】【P1123】【POI2008】【BLO】【题解】【割点】
- 1123: [POI2008]BLO tarjan求割点
- BOZJ 1123: [POI2008]BLO tarjan求割点
- 笔试10.19-2
- 解密Spring Boot整合Dubbo RPC框架
- Win 10 + CodeBlocks 配置 OpenGL
- LeetCode100. Same Tree
- C#一个服务器端多个客户端Socket通信
- bzoj 1123 BLO
- Bzoj 1036: [ZJOI2008]树的统计Count
- < 笔记 > Git
- OpenCV示例学习笔记(1)-contours2.cpp-通过findContours 函数实现轮廓提取
- CentOS7 安装 vlc
- 正则元字符
- Netty基本组件模型简单说明
- springboot 使用jsp 打包后无法访问
- 2017NOIP普及组初赛感想