#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long ll;
int n, m, uu, vv, hea[100005], cnt, siz[100005], dfn[100005], loo[100005], idx;
ll ans[100005];
bool ins[100005];
struct Edge{
int too, nxt;
}edge[1000005];
void add_edge(int fro, int too){
edge[++cnt].nxt = hea[fro];
edge[cnt].too = too;
hea[fro] = cnt;
}
void dfs(int x, int f){
dfn[x] = loo[x] = ++idx;
siz[x] = 1;
ins[x] = true;
int fla=0, sum=0;
bool isc=false;
for(int i=hea[x]; i; i=edge[i].nxt){
int t=edge[i].too;
if(!dfn[t]){
dfs(t, x);
siz[x] += siz[t];
loo[x] = min(loo[x], loo[t]);
if(loo[t]>=dfn[x]){
fla++;
sum += siz[t];
ans[x] += (ll)siz[t] * (n - siz[t]);
if(x!=1 || fla>1) isc = true;
}
}
else if(ins[t]) loo[x] = min(loo[x], dfn[t]);
}
// if(x==1) cout<<"1's isc: "<<isc<<endl;
if(isc) ans[x] += (ll)(n-sum-1)*(sum+1) + (n-1);
else ans[x] = 2 * (n - 1);
ins[x] = false;
}
int main(){
cin>>n>>m;
for(int i=1; i<=m; i++){
scanf("%d %d", &uu, &vv);
add_edge(uu, vv);
add_edge(vv, uu);
}
for(int i=1; i<=n; i++)
if(!dfn[i])
dfs(i, 0);
for(int i=1; i<=n; i++)
printf("%lld\n", ans[i]);
return 0;
}

luogu3469 [POI2008]BLO-Blockade的更多相关文章

  1. BZOJ 1123: [POI2008]BLO

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

  2. BZOJ1123: [POI2008]BLO

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

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

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

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

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

  5. [POI2008]BLO(Tarjan)

    [POI2008]BLO Description Byteotia城市有\(n\)个 towns \(m\)条双向roads. 每条 road 连接 两个不同的 towns ,没有重复的road. 所 ...

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

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

  7. 割点判断+luogu 3469 POI2008 BLO

    1.根节点,有2棵及以上子树 2.非根节点,有子节点dfn[u]<=low[v] #include <bits/stdc++.h> #define N 1000050 using n ...

  8. [POI2008] BLO

    link 试题分析 分两种情况考虑. 当此点不是割点是,答案是$2\times (n-1)$. 当是割点时,我们发现这个点把树分成了若干个联通块,只要两两相乘即可. #include<iostr ...

  9. BZOJ 1123 [POI2008]BLO(Tarjan算法)

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=1123 [题目大意] Byteotia城市有n个towns,m条双向roads. 每条r ...

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

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

随机推荐

  1. 轻量级的绘制图表js库--Morris.js

    Morris.js 是一个轻量级的 JS 库,使用 jQuery 和 Raphaël 来生成各种时序图. 虽说现在移动手机网络已经到了4G,但是在移动web客户端开发过中,为了达到良好的体验效果,需要 ...

  2. Redis数据库2

    一.存储list 1.概述     list类型是按照插入顺序排序的字符串链表,可以在头部(left)和尾部(right)添加新的元素,如果不存在,则自动创建;如果list中所有元素被移除,则list ...

  3. 织梦dedecms手机版上下篇链接错误的解决方法

    打开 \include\arc.archives.class.php 1. 找到 $this->PreNext['pre'] = "上一篇:<a href='$mlink'> ...

  4. JFinal教程:JFinal极速开发企业实战百集JFinal视频教程发布

    课程名称:JFinal极速开发企业实战 课程长度:100课时 课程作者:小木(909854136) 课程地址:http://edu.csdn.net/course/detail/1968 官网网址:h ...

  5. 微软大礼包 | 集合在线学习资源,助你秒变AI达人

    编者按:人工智能的浪潮正如火如荼地袭来,未来人工智能将大有所为,人们的生活轨迹也正在技术不断向前推进的过程中逐渐改变.人工智能不是科研人员或开发人员的专属,微软希望能够将人工智能带给每个人,从开发者到 ...

  6. $'\r': command not found 或者 syntax error: unexpected end of file 或者 syntax error near unexpected token `$'\r''

    执行shell脚本如果报如下错误: syntax error near unexpected token `$'\r'' syntax error: unexpected end of file $' ...

  7. 《大规模 web服务开发》笔记

    大规模服务:     可扩展,负载均衡,保证冗余,低运维成本,开发人数和开发方法的变化 数据处理:     磁盘—>内存—>缓存—>CPU 障碍:     持续增长的服务,”无法在内 ...

  8. java基础—GUI编程(一)

    一.AWT介绍

  9. C#访问数组元素

    在C#中,使用索引来访问数组元素.索引必须是一个整型值. 在数组中,每一个维度的索引从0开始. 一.访问一维数组元素 int[] array = {1,2,3,4,5,6,7,8,9,10}; // ...

  10. 八皇后问题(DFS)

    题目描述: 要在国际象棋棋盘中放八个皇后,使任意两个皇后都不能互相吃,皇后能吃同一行.同一列,同一对角线上(两个方向的对角线)的任意棋子.现在给一个整数n(n<=92),输出前n种的摆法. 输入 ...