当前位置:网站首页>【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;
}
边栏推荐
- 【iOS】Organization of interviews
- Ethernet channel Ethernet channel
- 想问下大佬们 ,cdc oracle初始化一张300万的表任务运行着后面就这个错 怎么解决哇
- 代码随想录笔记_动态规划_70爬楼梯
- WebView的优化与常见问题解决方案
- 【ECCV 2022|百万奖金】PSG大赛:追求“最全面”的场景理解
- 把相亲角搬到海外,不愧是咱爸妈
- A unit test report for CRM One Order Application log
- mSystems | Zhongnong Wang Jie Group Reveals the Mechanisms Affecting Soil "Plastic Interstitial" Microbial Communities
- Fragment的show和hide
猜你喜欢
WebView的优化与常见问题解决方案
系统的安全和应用(不会点安全的东西你怎么睡得着?)
Short read or OOM loading DB. Unrecoverable error, aborting now
借数据智能,亚马逊云科技助力企业打造品牌内生增长力
【量化交易行情不够快?】一文搞定通过Win10 wsl2 +Ubuntu+redis+pickle实现股票行情极速读写
BEVDet4D: Exploit Temporal Cues in Multi-camera 3D Object Detection Paper Notes
SenseTime self-developed robotic arm, the first product is an AI chess-playing robot: Guo Jingjing is also invited as an endorsement
MYSQL误删数据恢复
Redis上云迁移实践
一个 CRM One Order Application log 的单元测试报表
随机推荐
MYSQL误删数据恢复
LeetCode medium topic search of two-dimensional matrix
日志@Slf4j介绍使用及配置等级
Error: Rule can only have one resource source (provided resource and test + include + exclude)
Ethernet channel 以太信道
开源SPL消灭数以万计的数据库中间表
领域驱动实践总结(基本理论总结与分析V+架构分析与代码设计+具体应用设计分析)
Basic knowledge of switches
NodeJs原理 - Stream(二)
2022 Recruitment Notice for Academician Zhao Guoping Group of Shenzhen Institute of Advanced Technology, Chinese Academy of Sciences
22!Beijing Changping District notified catering service enterprises with food safety problems
Code Casual Recording Notes_Dynamic Programming_70 Climbing Stairs
R语言使用gt包和gtExtras包优雅地、漂亮地显示表格数据:gtExtras包的gt_highlight_rows函数高亮(highlight)表格中特定的数据行、配置高亮行的特定数据列数据加粗
Pod生命周期
3DS MAX batch export file script MAXScript with interface
Borg Maze (bfs+最小生成树)
WebView的优化与常见问题解决方案
Jenkins修改端口号, jenkins容器修改默认端口号
【ECCV 2022|百万奖金】PSG大赛:追求“最全面”的场景理解
R语言实战应用案例:论文篇(一)-特殊柱形图绘制