题目链接:传送门

题目大意:一副无向图,问有多少个节点满足删除该节点后图不连通,对于每个满足条件的节点,输出节点编号及删除节点将图分为几个连通块。若没有节点满足则输出No SPF nodes

题目思路:tarjan算法求关节点入门题(也可用矩阵存图)

 #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <stack>
#include <cctype>
#include <queue>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <climits>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define fi first
#define se second
#define ping(x,y) ((x-y)*(x-y))
#define mst(x,y) memset(x,y,sizeof(x))
#define mcp(x,y) memcpy(x,y,sizeof(y))
#define Min(x,y) (x<y?x:y)
#define Max(x,y) (x>y?x:y)
using namespace std;
#define gamma 0.5772156649015328606065120
#define MOD 100000007
#define inf 0x3f3f3f3f
#define N 1000005
#define maxn 1000050
typedef long long LL;
typedef pair<int,int> PII; int n,m,head[],hcnt,son,num;
int dfn[],low[],area[],vis[];
int deep;
struct Node{
int to,next;
Node(){}
Node(int a,int b):to(a),next(b){}
}node[];
inline void add(int x,int y){
node[hcnt]=Node(y,head[x]);
head[x]=hcnt++;
} void init(){
num=; ///最大节点的编号
hcnt=;
deep=; ///深度搜索树的深度优先数(第几个被搜索)
son=; ///记录根节点的子女个数
low[]=dfn[]=; ///low表示节点能通过子女和回边到达的最小深度优先数
mst(head,-); ///dfn表示节点的深度优先数
mst(vis,);
mst(area,); ///记录删除某个节点后图被分成了几块
vis[]=; ///标记节点是否访问过
} void dfs(int x){
for(int i=head[x];~i;i=node[i].next){
int e=node[i].to;
if(vis[e]) low[x]=Min(low[x],dfn[e]);
else{
vis[e]=;
dfn[e]=low[e]=++deep;
dfs(e);
low[x]=Min(low[x],low[e]);
if(low[e]>=dfn[x]){
if(x==) ++son;
else ++area[x];
}
}
}
} int main(){
int i,j,group,Case=,x,y;
while(scanf("%d",&x)!=EOF&&x){
init();
num=Max(num,x);
scanf("%d",&y);
num=Max(num,y);
add(x,y);
add(y,x);
while(scanf("%d",&x)&&x){
num=Max(num,x);
scanf("%d",&y);
num=Max(num,y);
add(x,y);
add(y,x);
}
if(Case)printf("\n");
printf("Network #%d\n",++Case);
dfs();
if(son>)area[]=son-;
int flag=;
for(i=;i<=num;++i)if(area[i]){
flag=;
printf(" SPF node %d leaves %d subnets\n",i,area[i]+);
}
if(!flag) printf(" No SPF nodes\n");
}
return ;
}

ZOJ1119(SPF)的更多相关文章

  1. POJ1523 SPF[无向图割点]

    SPF Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8139   Accepted: 3723 Description C ...

  2. 【POJ 1523】SPF(割点)

    儿子数大于1的树根或者 Low[v] >= DFN[u]的非树根节点v 就是割点. #include <cstdio> #include <cstring> const ...

  3. 自动SPF生成工具

    到openspf网站去自动生成一下,地址是http://old.openspf.org/wizard.html.详细解释见下图关于spf的详细语法请看http://www.openspf.org/SP ...

  4. SPF 简介

    SPF 简介 摘要: SPF 是发送方策略框架 (Sender Policy Framework) 的缩写,希望能成为一个防伪标准,来防止伪造邮件地址.这篇文章对 SPF 进行了简单介绍,并介绍了它的 ...

  5. POJ1523 SPF

    Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8254   Accepted: 3772 Description Consi ...

  6. POJ 1523 SPF tarjan求割点

                                                                   SPF Time Limit: 1000MS   Memory Limit ...

  7. POJ1523 SPF(割点模板)

    题目求一个无向图的所有割点,并输出删除这些割点后形成几个连通分量.用Tarjan算法: 一遍DFS,构造出一颗深度优先生成树,在原无向图中边分成了两种:树边(生成树上的边)和反祖边(非生成树上的边). ...

  8. POJ 1523 SPF(寻找关节点)

                                                                         SPF Time Limit: 1000MS   Memory ...

  9. 如何设置DNS的SPF记录

    如何设置DNS的SPF记录 Introduction SPF的完整意思为 "Sender Policy Framework".翻译过来就是发送方策略框架,是一项跟 DNS 相关的技 ...

随机推荐

  1. C#秘密武器之LINQ to SQL

    LINQ to SQL语句(1)之Where 适用场景:实现过滤,查询等功能. 说明:与SQL命令中的Where作用相似,都是起到范围限定也就是过滤作用的,而判断条件就是它后面所接的子句.Where操 ...

  2. Python 3 初探,第 2 部分: 高级主题

    Python 3 是 Guido van Rossum 功能强大的通用编程语言的最新版本.它虽然打破了与 2.x 版本的向后兼容性,但却清理了某些语法方面的问题.本文是这个由两部分组成的系列文章中的第 ...

  3. hdu 1348 Wall (凸包模板)

    /* 题意: 求得n个点的凸包.然后求与凸包相距l的外圈的周长. 答案为n点的凸包周长加上半径为L的圆的周长 */ # include <stdio.h> # include <ma ...

  4. 《深入PHP:面向对象、模式与实践》(一)

    第1章  PHP:设计与管理 本章主要介绍了本书有哪些内容. 第2章  PHP与对象 本章总结了PHP面向对象特性的发展过程,逐步介绍对象的概念. PHP/FI:支持变量.关联数组和函数.没有对象. ...

  5. src和href使用总结

    src img 图片 <img src="/img/1.png" alt="1" /> rame iframe 框架集 <iframe src ...

  6. VS2017、netcore版本更新升级

    VS2017 剩下的就是下一步了. netcore 访问:https://www.microsoft.com/net/download/archives 找到对应版本(最新版本) 下载安装就可以了 装 ...

  7. win10 rabbitMQ的安装与测试

    安装 1.首先,下载并运行Erlang for Windows 安装程序 (地址:http://www.erlang.org/downloads)下载完毕并安装(注意:安装目录请选择默认目录) 2.下 ...

  8. EMQ ---100万线连接测试说明

    注解 EMQ 2.0 消息服务器默认设置,允许最大客户端连接是512,因为大部分操作系统 ‘ulimit -n’ 限制为1024. EMQ 消息服务器1.1.3版本,连接压力测试到130万线,8核心/ ...

  9. atitit.guice3 绑定方式打总结生成非单例对象toInstance toProvider区别 v2 pb29

    atitit.guice3 绑定方式打总结生成非单例对象toInstance toProvider区别 v2 pb29 1. 三 绑定方式的介绍1 2. To接口,链式绑定,用的最多的1 3. toC ...

  10. web info

    http://blog.csdn.net/qq_24473141/article/details/51363662 http://blog.sina.com.cn/s/blog_8e392fc2010 ...