题目链接:https://vjudge.net/problem/UVA-315

题目:求割点。

 #include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std; const int N = ;
int n,tim,tot,root = ;
int head[N],dfn[N],low[N],poi[N];
struct node{
int to;
int nxt;
}e[N*N]; void init(){
for(int i = ; i <= n; ++i){
head[i] = -;
dfn[i] = poi[i] = ;
}
tim = tot = ;
} inline void add(int u,int v){
e[tot].to = v;
e[tot].nxt = head[u];
head[u] = tot++;
} void tarjan(int now,int pre){
dfn[now] = low[now] = ++tim;
int to,son = ;
for(int o = head[now]; ~o; o = e[o].nxt){
to = e[o].to;
if(to == pre) continue; //处理无向图的双向边问题
if(!dfn[to]){
++son;
tarjan(to,now);
low[now] = min(low[now],low[to]);
//割点条件1
if(now != root && dfn[now] <= low[to]) poi[now] = ;
}
else if(low[now] > dfn[to]) low[now] = dfn[to];
}
//割点条件2
if(now == root && son >= ) poi[now] = ;
} int main(){ int u,v;
char ch; while(~scanf("%d",&n) && n){
init(); while(~scanf("%d",&u) && u){
while(~scanf("%d%c",&v,&ch)){
add(u,v); add(v,u);
if(ch == '\n') break;
}
}
tarjan(,);
int ans = ;
for(int i = ; i <= n; ++i)
if(poi[i]) ++ans; printf("%d\n",ans);
} return ;
}

kuangbin专题 专题九 连通图 Network UVA - 315的更多相关文章

  1. [kuangbin带你飞]专题九 连通图B - Network UVA - 315

    判断割点的性质: 如果点y满足 low[y]>=dfn[x] 且不是根节点 或者是根节点,满足上述式子的有两个及其以上. 就是割点 如果是起点,那么至少需要两个子节点满足上述条件,因为它是根节点 ...

  2. B - Network - uva 315(求割点)

    题意:给一个无向连通图,求出割点的数量. 首先输入一个N(多实例,0结束),下面有不超过N行的数,每行的第一个数字代表后面的都和它存在边,0表示行输入的结束(很蛋疼的输入方式). 分析:割点的模板题 ...

  3. Network UVA - 315(求割点)

    #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> ...

  4. Network UVA - 315 无向图找割点

    题意: 给你一个无向图,你需要找出来其中有几个割点 割点/割项: 1.u不为搜索起点,low[v]>=dfn[u] 2.u为搜索起点,size[ch]>=2 3.一般情况下,不建议在tar ...

  5. [kuangbin带你飞]专题九 连通图

        ID Origin Title   76 / 163 Problem A POJ 1236 Network of Schools   59 / 177 Problem B UVA 315 Ne ...

  6. 「kuangbin带你飞」专题十九 矩阵

    layout: post title: 「kuangbin带你飞」专题十九 矩阵 author: "luowentaoaa" catalog: true tags: mathjax ...

  7. UVA 315 求割点 模板 Tarjan

    D - D Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Pract ...

  8. kuangbin专题 专题九 连通图 POJ 3694 Network

    题目链接:https://vjudge.net/problem/POJ-3694 题目:给定一个连通图,求桥的个数,每次查询,加入一条边,问加入这条边后还有多少个桥. 思路:tarjan + 并查集 ...

  9. kuangbin专题 专题九 连通图 POJ 1236 Network of Schools

    题目链接:https://vjudge.net/problem/POJ-1236 题目:有向图,有若干个连通图,点之间有单向边边就可以单向传递信息,问: (1)至少需要发送几份信息才能使得每个点都传递 ...

随机推荐

  1. P5048 [[Ynoi2019模拟赛]Yuno loves sqrt technology III]

    为什么我感觉这题难度虚高啊-- 区间众数的出现次数- 计算器算一下 \(\sqrt 500000 = 708\) 然后我们发现这题的突破口? 考虑分块出来[L,R]块的众数出现个数 用 \(\text ...

  2. immutability-helper 用途+使用方法

    1.react 官网文章 2.github地址  

  3. 《操作系统真象还原》bochs安装

    在安装bochs之前,我们先需要安装虚拟机和linux发行版,也可以安装双系统,总之有个linux操作系统就好. 我是在ubuntu14.04系统下安装bochs的. 安装Bochs 以下为安装步骤 ...

  4. python接口自动化-requests-toolbelt处理multipart/form-data

    1.requests-toolbelt官方文档:https://pypi.org/project/requests-toolbelt/ 2.环境安装 pip install requests-tool ...

  5. jdk1.8的HashMap和ConcurrentHashMap

    原文地址:https://my.oschina.net/pingpangkuangmo/blog/817973 本文针对jdk1.8的ConcurrentHashMap 1 1.8的HashMap设计 ...

  6. 【分享】一款特别轻量的gif生成工具

    github链接:https://github.com/NickeManarin/ScreenToGif/releases/tag/2.19.3 超级好用!支持多种方式(摄像头也可√)录制gif

  7. Python基本数据类型set方法概述

    li=[1,2,3,4,5,6,3,2,1] s2 = set(li) print(set(li)) #difference()去除相同项,生成一个新的集合,删除 s3=s2.difference([ ...

  8. eclipse unable to start within 45 seconds

    在eclipse4.8.2中运行tomcat8.5项目时,提示出错: Server Tomcat v8.0 Server at localhost was unable to start within ...

  9. 二分-B - Dating with girls(1)

    B - Dating with girls(1) Everyone in the HDU knows that the number of boys is larger than the number ...

  10. PP: Pattern Trails: visual analysis of pattern transitions in subspaces

    Problem: 1. We can't find patterns in full attribute space, and patterns may only be found in smalle ...