Uva 315 Network 判断割点
模板题,注意输出
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <stack>
using namespace std;
typedef long long LL;
const int N = 1e2+;
int head[N],tot,n;
struct Edge{
int v,next;
}edge[N*N];
bool iscut[N];
void add(int u,int v){
edge[tot].v=v;
edge[tot].next=head[u];
head[u]=tot++;
}
int dfn[N],low[N],clk;
void targin(int u,int f){
dfn[u]=low[u]=++clk;
int child=;
for(int i=head[u];~i;i=edge[i].next){
int v=edge[i].v;
if(v==f)continue;
if(!dfn[v]){
++child;
targin(v,u);
low[u]=min(low[u],low[v]);
if(f!=-&&low[v]>=dfn[u])iscut[u]=true;
}
else if(dfn[v]<low[u])low[u]=dfn[v];
}
if(f==-&&child>)iscut[u]=true;
}
int main(){
while(~scanf("%d",&n),n){
memset(head,-,sizeof(head));clk=tot=;
for(int u;;){
scanf("%d",&u);
if(!u)break;
for(int v;;){
scanf("%d",&v);
add(u,v);
add(v,u);
char c=getchar();
if(c=='\n')break; }
}
memset(iscut,false,sizeof(iscut));
memset(dfn,,sizeof(dfn));
memset(low,,sizeof(low));
for(int i=;i<=n;++i)
if(!dfn[i])targin(i,-);
int ans=;
for(int i=;i<=n;++i)
if(iscut[i])++ans;
printf("%d\n",ans);
}
return ;
}
Uva 315 Network 判断割点的更多相关文章
- uva 315 Network(无向图求割点)
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- hrbustoj 1494(原题UVA 315 Network) 解题报告 tarjan求割点
主要思路:使用tarjan选取一个根节点建立一个棵搜索树,判断一个点是割点的充分必要条件是,对于一个节点u如果他的孩子节点v的low值大于等于u的出生日期dfn值,进行下一步判断,如果u是我们选的根节 ...
- UVA - 315 Network(tarjan求割点的个数)
题目链接:https://vjudge.net/contest/67418#problem/B 题意:给一个无向连通图,求出割点的数量.首先输入一个N(多实例,0结束),下面有不超过N行的数,每行的第 ...
- Network UVA - 315 无向图找割点
题意: 给你一个无向图,你需要找出来其中有几个割点 割点/割项: 1.u不为搜索起点,low[v]>=dfn[u] 2.u为搜索起点,size[ch]>=2 3.一般情况下,不建议在tar ...
- 无向图求割点 UVA 315 Network
输入数据处理正确其余的就是套强联通的模板了 #include <iostream> #include <cstdlib> #include <cstdio> #in ...
- B - Network - uva 315(求割点)
题意:给一个无向连通图,求出割点的数量. 首先输入一个N(多实例,0结束),下面有不超过N行的数,每行的第一个数字代表后面的都和它存在边,0表示行输入的结束(很蛋疼的输入方式). 分析:割点的模板题 ...
- UVA 315 Network (模板题)(无向图求割点)
<题目链接> 题目大意: 给出一个无向图,求出其中的割点数量. 解题分析: 无向图求割点模板题. 一个顶点u是割点,当且仅当满足 (1) u为树根,且u有多于一个子树. (2) u不为树根 ...
- Network UVA - 315(求割点)
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> ...
- UVA 315 求割点 模板 Tarjan
D - D Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit Status Pract ...
随机推荐
- sharepoint warmup
/---------------- using System;using System.Collections.Generic; using System.Text;using System.Net; ...
- bnuoj 29373 Key Logger(模拟双向队列)
http://www.bnuoj.com/bnuoj/problem_show.php?pid=29373 [题意]:模拟光标输入 [题解]:用双向列表模拟实现,这里用其他模拟会超时,注意内存的释放 ...
- C#设计模式学习资料--观察者模式
http://www.cnblogs.com/promise-7/archive/2012/05/14/2500759.html http://www.cnblogs.com/zhenyulu/art ...
- 5.0:Spring-bean的加载
内容来自<Spring深度解析>,之后的不一一复述! 在Spring中,最基本的IOC容器接口是BeanFactory - 这个接口为具体的IOC容器的实现作了最基本的功能规定 - 不管怎 ...
- vncserver 添加用户
1.在vncserver设置登录用户的信息 #vi /etc/sysconfig/vncservers VNCSERVERS="1:root 2:wt" 此处添加用户 ...
- 让Flash背景透明兼容Firefox、IE 6和IE 7的代码
添加代码: <param name="wmode" value="transparent" > 到 <object>…</obje ...
- 团体程序设计天梯赛-练习集L2-010. 排座位
L2-010. 排座位 时间限制 150 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 布置宴席最微妙的事情,就是给前来参宴的各位宾客安排座位. ...
- uva 10051
将每一个分解为六个两面的 简单地dp 回溯输出路径..... #include <cstdio> #include <cstring> #include <cmath&g ...
- DLL搜索路径和DLL劫持
DLL搜索路径和DLL劫持 环境:XP SP3 VS2005 作者:magictong 为什么要把DLL搜索路径(DLL ORDER)和DLL劫持(DLL Hajack)拿到一起讲呢?呵呵,其实没啥深 ...
- 【leetcode】Container With Most Water(middle)
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). ...