当前位置:网站首页>【POI 2008, BLO】Cut Point
【POI 2008, BLO】Cut Point
2022-08-10 13:33:00 【Uchiha one hit seven~】
题目描述
有n个点mA graph of edge undirected connected graphs,保证没有重边和自环.对于每个点,The output removes all edges from this point,How many point pairs cannot be connected to each other.The point pairs here are in order,也就是(u,v)和(v,u)need to be counted twice.
输入格式
第一行包含两个数n,m(1≤n≤105,1≤m≤5×105).
接下来m行,每行两个整数u,v表示一条无向边.
输出格式
n行,每行一个整数,表示答案.
样例输入
5 5
1 2
2 3
1 3
3 4
4 5
样例输出
8
8
16
14
8
思路
对于每一个点,如果这个点是割点,Then after deleting him, it has no effect on this picture,So the contribution of this point is2*(n-1),If this point is a cut point,Then multiply all the connected blocks that delete it,Pay attention to the process of seeking that cut edge,That is, if the point connected to this point does not have a leaseback edge, it is a cut point,下面看代码吧
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
const int N = 1e5+10;
vector<pair<int,int> > e[N];
int n,m,dfn[N],ins[N],low[N],idx,sz[N];
long long ans[N];
void dfs(int u,int id){
dfn[u] = low[u] = ++idx;
ins[u] = true;
sz[u] = 1;
ans[u] = n-1;
int cut = n-1;
for(auto pi : e[u]){
int v = pi.first,idd = pi.second;
if(!dfn[v]){
dfs(v,idd);
sz[u] += sz[v];
low[u] = min(low[u],low[v]);
if(low[v] >= dfn[u]){
ans[u] += 1ll*(n-sz[v])*sz[v];
cut -= sz[v];
}
}
else if(idd != id){
low[u] = min(low[u],dfn[v]);
}
}
ans[u] += 1ll*(cut)*(n-cut);
}
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=m;i++){
int a,b;
scanf("%d%d",&a,&b);
e[a].pb({
b,i});e[b].pb({
a,i});
}
dfs(1,-1);
for(int i=1;i<=n;i++) printf("%lld\n",ans[i]);
return 0;
}
边栏推荐
- Network Saboteur
- MYSQL误删数据恢复
- Codeforces Round #276 (Div. 1) B. Maximum Value
- The recursive recursive Fighting_ silver study ah but level 4
- 鸿蒙开发从hello world开始
- 学习日记9
- CodeForces - 834C
- 【MinIO】工具类使用
- mSystems | Zhongnong Wang Jie Group Reveals the Mechanisms Affecting Soil "Plastic Interstitial" Microbial Communities
- 【mysql索引实现原理】
猜你喜欢

Solution for "Certificate not valid for requested usage" after Digicert EV certificate signing

Detailed explanation of es6-promise object

G1和CMS的三色标记法及漏标问题

bgp dual plane experiment routing strategy to control traffic

Efficient and Robust 2D-to-BEV Representation Learning via Geometry-guided Kernel Transformer Paper Notes

记录几道整型提升的题目

MYSQL误删数据恢复

Error: Rule can only have one resource source (provided resource and test + include + exclude)

2022 Recruitment Notice for Academician Zhao Guoping Group of Shenzhen Institute of Advanced Technology, Chinese Academy of Sciences

2022-08-09:以下go语言代码输出什么?A:否,会 panic;B:是,能正确运行;C:不清楚,看投票结果。 package main import ( “fmt“ “syn
随机推荐
Loudi Center for Disease Control and Prevention Laboratory Design Concept Description
【iOS】Organization of interviews
借数据智能,亚马逊云科技助力企业打造品牌内生增长力
ArcMAP has a problem of -15 and cannot be accessed [Provide your license server administrator with the following information:Err-15]
AWS 安全基础知识
AtCoder初学者比赛077 D -小多
2022-08-09:以下go语言代码输出什么?A:否,会 panic;B:是,能正确运行;C:不清楚,看投票结果。 package main import ( “fmt“ “syn
八大排序总是忘?快来这里~
Proprietary cloud ABC Stack, the real strength!
C# InitializeComponent() does not exist in the current context
Shell:数组
3DS MAX batch export file script MAXScript with interface
Efficient and Robust 2D-to-BEV Representation Learning via Geometry-guided Kernel Transformer Paper Notes
Short read or OOM loading DB. Unrecoverable error, aborting now
递归递推之计算组合数
BEVDet4D: Exploit Temporal Cues in Multi-camera 3D Object Detection Paper Notes
OpenStack-related commands that need to be recorded _ self-use
R语言使用gt包和gtExtras包优雅地、漂亮地显示表格数据:gtExtras包的gt_highlight_rows函数高亮(highlight)表格中特定的数据行、配置高亮行的特定数据列数据加粗
Reversing words in a string in LeetCode
Fragment-hide和show