#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. 微信开发 config:invalid url domain

    当遇到config:invalid url domain 有2种可能 1.没有配置url. 2.url配置错误.配置url如http://write.blog.csdn.NET/,就要这样配置writ ...

  2. Home is where your heart is

    Home is where your heart is.心之所在即为家.

  3. jquery笔记1--选择器

    一.概述:jQuery是一个快速.简洁的JavaScript框架,是继Prototype之后又一个优秀的JavaScript代码库(或JavaScript框架).jQuery设计的宗旨是“write ...

  4. springmvc学习经验

    Spring MVC属于SpringFrameWork的后续产品,已经融合在Spring Web Flow里面.Spring 框架提供了构建 Web 应用程序的全功能 MVC 模块.使用 Spring ...

  5. linux mount命令详解(iso文件挂载)

    挂载命令:   mount [-t vfstype] [-o options] device dir   mount 是挂载命令 -t + 类型 -o + 属性 device iso的文件 dir 挂 ...

  6. cpp 计算程序运行时间的两种方法

    1. #include <time.h> time_t begin_t = clock(); // to do time_t finish_t = clock(); cout<< ...

  7. GIT新手入门学习教程

    廖雪峰的GIT教程 链接地址:https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000

  8. PHP的socket通信原理及实现

    对TCP/IP.UDP.Socket编程这些词你不会很陌生吧?随着网络技术的发展,这些词充斥着我们的耳朵.那么我想问: 1.         什么是TCP/IP.UDP?2.         Sock ...

  9. 分享eclipse自动生成java注释方法

    设置方法介绍: eclipse中:Windows->Preferences->Java->Code Style->Code Template->Comments,然后对应 ...

  10. 个人作业-Alpha项目测试

    姓名 蒋东航 学号 201731062328 这个作业属于哪个课程 课程链接 这个作业要求在哪里 作业要求链接 团队名称 机你太美(团队博客链接) 这个作业的目标 了解其他团队项目,学习其他团队优秀方 ...