当前位置:网站首页>【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;
}
边栏推荐
- 数据产品经理那点事儿 二
- Matrix Keyboard & Calculator Small Project Based on 51 (UcosII)
- 瑞幸「翻身」?恐言之尚早
- Loudi Cosmetics Laboratory Construction Planning Concept
- Short read or OOM loading DB. Unrecoverable error, aborting now
- Efficient and Robust 2D-to-BEV Representation Learning via Geometry-guided Kernel Transformer Paper Notes
- C# InitializeComponent() does not exist in the current context
- BEVDet4D: Exploit Temporal Cues in Multi-camera 3D Object Detection 论文笔记
- Codeforces Round #276 (Div. 1) B. Maximum Value
- Cloud Migration Practice of Redis
猜你喜欢
Stream通过findFirst()查找满足条件的一条数据
Solution for "Certificate not valid for requested usage" after Digicert EV certificate signing
Blast!ByteDance successfully landed, only because the interview questions of LeetCode algorithm were exhausted
Jenkins修改端口号, jenkins容器修改默认端口号
AWS 安全基础知识
MySQL面试题整理
DNS欺骗-教程详解
矩阵键盘&基于51(UcosII)计算器小项目
bgp双平面实验 路由策略控制流量
表中存在多个索引问题? - 聚集索引,回表,覆盖索引
随机推荐
【iOS】Organization of interviews
发送post请求前台无法获取数据
Ethernet channel Ethernet channel
开源SPL消灭数以万计的数据库中间表
SecureCRTPortable – 破解
Fragment-hide and show
简单的写一个防抖跟节流
Short read or OOM loading DB. Unrecoverable error, aborting now
C# 当前上下文中不存在InitializeComponent()
SenseTime self-developed robotic arm, the first product is an AI chess-playing robot: Guo Jingjing is also invited as an endorsement
Loudi Center for Disease Control and Prevention Laboratory Design Concept Description
shell:常用小工具(sort、uniq、tr、cut)
大佬们有遇到过这个问题吗? MySQL 2.2 和 2.3-SNAPSHOT 都这样,貌似是
Inventory of Loudi Agricultural Products Inspection Laboratory Construction Guidelines
C# WPF image is displayed without problems, but the solution does not display the image at runtime
领域驱动实践总结(基本理论总结与分析V+架构分析与代码设计+具体应用设计分析)
DNS欺骗-教程详解
22!Beijing Changping District notified catering service enterprises with food safety problems
AtCoder初学者比赛077 D -小多
数据产品经理那点事儿 二