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. Codeforces Round #236 (Div. 2)E. Strictly Positive Matrix(402E)

    E. Strictly Positive Matrix   You have matrix a of size n × n. Let's number the rows of the matrix f ...

  2. c# 可变性解析(协变和逆变)

    之所以会想写关于协变和逆变的知识点,主要是因为在泛型委托中提到了这个知识点. 1.什么是可变性 可变性是.NET4.0中的一个特性,可变形分为:协变性,逆变性,不可变性. 2.在.NET4.0出来之前 ...

  3. java并发编程--Runnable Callable及Future

    1.Runnable Runnable是个接口,使用很简单: 1. 实现该接口并重写run方法 2. 利用该类的对象创建线程 3. 线程启动时就会自动调用该对象的run方法 通常在开发中结合Execu ...

  4. 【C#爬虫】抓取XX网站mp4资源地址

    抓取小视频的url地址,然后将地址信息拷贝到迅雷里批量下载就ok了 主程序 代码 //yazhouqingseAV 35 //zhifusiwaAV 29 //zipaishipin 30 //oum ...

  5. magento产品eav笔记【持续跟新...】

    //magento把产品信息分在子表中,最顶上的表是catalog_product_entity,仅仅包含产品的信息(SKU) //表eav_attribute,这张表在magento里为全部不 同的 ...

  6. Dynamics CRM记录页面上隐藏子网格“+”标识

    前段时间微软发布了Dynamics 365,这是Dynamics产品的又一次大的变动,期待新的版本能够更好的满足客户的需求,同时提供更多的可定制化的内容. 近期做Dynamics CRM项目遇到很多审 ...

  7. Python进阶之路---1.5python数据类型-字符串

    字符串 *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important; ...

  8. windows快捷键命令汇总整理

        访问当前屏幕的设置,打开"设置"栏 按 Windows 徽标键+"i"打开当前屏幕(例如,"开始".桌面或 Windows 应用)的 ...

  9. 在浏览器中就可以写F#程序了,你试试吧

    学习F#有一种简单办法,不需要安装Visual Studio,在浏览器中就可以写F#了,非常方便,进入下面的链接,你可以试试. http://www.tryfsharp.org/Learn

  10. System.Net网络编程--AuthenticationManager和IAuthenticationModule

    AuthenticationManager——管理客户端身份验证过程中调用的身份验证模块. public class Demo1 { private static string username, p ...