博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
bzoj 1123: [POI2008]BLO(Trajan求割点)
阅读量:2143 次
发布时间:2019-04-30

本文共 1160 字,大约阅读时间需要 3 分钟。

Time Limit: 10 Sec  
Memory Limit: 162 MB
Submit: 1468  
Solved: 678
[ ][ ][ ]

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

被删掉的点要算进答案,并且(u, v)和(v, u)属于不同点对

模板题

#include
#include
#include
using namespace std;#define LL long longvector
G[100005];int n, cnt, cut[100005], time[100005], low[100005], id[100005], vis[100005];LL ans[100005];void Tarjan(int u, int p){ int i, v, temp, size, child = 0; vis[u] = 1, low[u] = time[u] = ++cnt; temp = cnt, size = 0; for(i=0;i
1 || p!=0 && low[v]>=time[u]) { cut[u] = 1; ans[u] += (LL)(cnt-temp)*(n-1-cnt+temp); size += cnt-temp; } temp = cnt; } else low[u] = min(low[u], time[v]); } if(cut[u]) ans[u] += (LL)size*(n-1-size);}int main(void){ int m, i, x, y; scanf("%d%d", &n, &m); for(i=1;i<=m;i++) { scanf("%d%d", &x, &y); G[x].push_back(y); G[y].push_back(x); } for(i=1;i<=n;i++) ans[i] = (n-1)*2; Tarjan(1, 0); for(i=1;i<=n;i++) printf("%lld\n", ans[i]); return 0;}

转载地址:http://jqmgf.baihongyu.com/

你可能感兴趣的文章
Tomcat 7优化前及优化后的性能对比
查看>>
Java Guava中的函数式编程讲解
查看>>
Eclipse Memory Analyzer 使用技巧
查看>>
tomcat连接超时
查看>>
谈谈编程思想
查看>>
iOS MapKit导航及地理转码辅助类
查看>>
检测iOS的网络可用性并打开网络设置
查看>>
简单封装FMDB操作sqlite的模板
查看>>
iOS开发中Instruments的用法
查看>>
iOS常用宏定义
查看>>
什么是ActiveRecord
查看>>
有道词典for mac在Mac OS X 10.9不能取词
查看>>
关于“团队建设”的反思
查看>>
利用jekyll在github中搭建博客
查看>>
Windows7中IIS简单安装与配置(详细图解)
查看>>
linux基本命令
查看>>
BlockQueue 生产消费 不需要判断阻塞唤醒条件
查看>>
强引用 软引用 弱引用 虚引用
查看>>
数据类型 java转换
查看>>
"NetworkError: 400 Bad Request - http://172.16.47.117:8088/rhip/**/####t/approval?date=976
查看>>