1123: [POI2008]BLO

Time Limit: 10 Sec  Memory Limit: 162 MB
Submit: 614  Solved: 235
[Submit][Status]

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

HINT

Source

题解:

这题应该是裸的求割点,但应该我还不会,所以去学习了一下。。。

道理很简单,上篇博文里讲的很清楚。

hzwer关于此题的题解:
 把某个割点去掉以后,会出现几个连通块,它们之间不能互相到达

即会分成上面一棵树,下面若干子树

子树之间不互通,所有子树和上面那个树不互通,通过记录树的大小统计答案

另外删去的点和其它点不互通

------------------------------------------

应该是显然的吧。

代码:

 #include<cstdio>

 #include<cstdlib>

 #include<cmath>

 #include<cstring>

 #include<algorithm>

 #include<iostream>

 #include<vector>

 #include<map>

 #include<set>

 #include<queue>

 #include<string>

 #define inf 1000000000

 #define maxn 100000+1000

 #define maxm 500000+1000

 #define eps 1e-10

 #define ll long long

 #define pa pair<int,int>

 #define for0(i,n) for(int i=0;i<=(n);i++)

 #define for1(i,n) for(int i=1;i<=(n);i++)

 #define for2(i,x,y) for(int i=(x);i<=(y);i++)

 #define for3(i,x,y) for(int i=(x);i>=(y);i--)

 #define mod 1000000007

 using namespace std;

 inline int read()

 {

     int x=,f=;char ch=getchar();

     while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}

     while(ch>=''&&ch<=''){x=*x+ch-'';ch=getchar();}

     return x*f;

 }
int head[maxn],low[maxn],dfn[maxn],ti,n,m,tot;
ll s[maxn],ans[maxn];
struct edge{int go,next;}e[*maxm];
inline void insert(int x,int y)
{
e[++tot].go=y;e[tot].next=head[x];head[x]=tot;
e[++tot].go=x;e[tot].next=head[y];head[y]=tot;
}
inline void dfs(int x)
{
ll t=;
s[x]=;
low[x]=dfn[x]=++ti;
for(int i=head[x],y;i;i=e[i].next)
if(!dfn[y=e[i].go])
{
dfs(y);
s[x]+=s[y];
low[x]=min(low[x],low[y]);
if(low[y]>=dfn[x])
{
ans[x]+=t*s[y];
t+=s[y];
}
}
else low[x]=min(low[x],dfn[y]);
ans[x]+=t*(n-t-);
} int main() { freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); n=read();m=read();
for1(i,m)insert(read(),read());
dfs();
for1(i,n)printf("%lld\n",(ans[i]+n-)*); return ; }

BZOJ1123: [POI2008]BLO的更多相关文章

  1. 【dfs+连通分量】Bzoj1123 POI2008 BLO

    Description Byteotia城市有n个 towns m条双向roads. 每条 road 连接 两个不同的 towns ,没有重复的road. 所有towns连通. Input 输入n&l ...

  2. BZOJ1123:[POI2008]BLO(双连通分量)

    Description Byteotia城市有n个 towns m条双向roads. 每条 road 连接 两个不同的 towns ,没有重复的road. 所有towns连通. Input 输入n&l ...

  3. bzoj1123 [POI2008]BLO——求割点子树相乘

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1123 思路倒是有的,不就是个乘法原理吗,可是不会写...代码能力... 写了一堆麻麻烦烦乱七 ...

  4. BZOJ1123 [POI2008]BLO(割点判断 + 点双联通缩点size)

    #include <iostream> #include <cstring> #include <cstdio> using namespace std; type ...

  5. [BZOJ1123]:[POI2008]BLO(塔尖)

    题目传送门 题目描述 Byteotia城市有n个towns.m条双向roads.每条road连接两个不同的towns,没有重复的road.所有towns连通. 输入格式 输入n,m及m条边. 输出格式 ...

  6. 【BZOJ-1123】BLO Tarjan 点双连通分量

    1123: [POI2008]BLO Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 970  Solved: 408[Submit][Status][ ...

  7. BZOJ 1123: [POI2008]BLO

    1123: [POI2008]BLO Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 1030  Solved: 440[Submit][Status] ...

  8. BZOJ 1123: [POI2008]BLO( tarjan )

    tarjan找割点..不是割点答案就是(N-1)*2, 是割点的话就在tarjan的时候顺便统计一下 ------------------------------------------------- ...

  9. bzoj 1123 [POI2008]BLO Tarjan求割点

    [POI2008]BLO Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 1540  Solved: 711[Submit][Status][Discu ...

随机推荐

  1. powerdesigner 字段大小写转换\id 自增

    转换:tools --> model options-->naming convention  name code 自增: 在你所要设为自增型的键上(比如你的id)双击 ,弹出一个Colu ...

  2. http断点续传原理:http头 Range、Content-Range

    所谓断点续传,也就是要从文件已经下载的地方开始继续下载.在以前版本的 HTTP 协议是不支持断点的,HTTP/1.1 开始就支持了.一般断点下载时才用到 Range 和 Content-Range 实 ...

  3. 控制uibutton的title范围

    moreBtn.contentEdgeInsets = UIEdgeInsetsMake(0,10, 0, 10);

  4. c++Socket 异步通讯

    在网络通讯中,由于网络拥挤或一次发送的数据量过大等原因,经常会发生交换的数据在短时间内不能传送完,收发数据的函数因此不能返回,这种现象叫做阻塞. Winsock对有可能阻塞的函数提供了两种处理方式:阻 ...

  5. C复习手记(Day4)

    1.C错误处理 errno.perror() 和sterror() perror() 函数显示您传给它的字符串,后跟一个冒号.一个空格和当前 errno 值的文本表示形式. strerror() 函数 ...

  6. linux 使用ptrace函数时找不到头文件 .h 或者找不到某个宏的解决方法

    例如: #include <stdio.h> #include <sys/ptrace.h> #include <sys/types.h> #include < ...

  7. Swift 流程控制

    import Foundation ...{ == { print(index) } } // 可选变量 类型后面加? var myName:String?="jikexueyuan&quo ...

  8. reason: 'Could not instantiate class named MKMapView'

    详细原因: 拖入MapView直接运行,结果报错 解决:在Xcode导入MapKit.framework既可

  9. out返回值的用法与用途

    static void Main(string[] arr) { Console.WriteLine("请输入用户名"); string uname = Console.ReadL ...

  10. JavaWeb学习笔记之Servlet(一)

    1. 引子: 当我们开始进入JavaWeb开发的学习时,我们就必须要和Servlet和HTTP这两个词进行打交道了,尤其是Servlet.即使到了后面使用JSP (我们知道JSP其本身就是一个Serv ...