http://poj.org/problem?id=1144 (题目链接)

题意

  求无向图的割点。

Solution

  Tarjan求割点裸题。并不知道这道题的输入是什么意思,也不知道有什么意义= =,欺负我英语不好是吗。。。

代码

// poj1144
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<set>
#define MOD 1000000007
#define inf 2147483640
#define LL long long
#define free(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout);
using namespace std;
inline LL getint() {
LL x=0,f=1;char ch=getchar();
while (ch>'9' || ch<'0') {if (ch=='-') f=-1;ch=getchar();}
while (ch>='0' && ch<='9') {x=x*10+ch-'0';ch=getchar();}
return x*f;
} const int maxn=200;
struct edge {int to,next;}e[maxn<<2];
int head[maxn],p[maxn],dfn[maxn],low[maxn],f[maxn];
int cnt,root,n,ind; void link(int u,int v) {
e[++cnt].to=v;e[cnt].next=head[u];head[u]=cnt;
e[++cnt].to=u;e[cnt].next=head[v];head[v]=cnt;
}
void Tarjan(int u,int fa) {
dfn[u]=low[u]=++ind;
f[u]=1;
for (int i=head[u];i;i=e[i].next) if (e[i].to!=fa) {
if (!f[e[i].to]) {
Tarjan(e[i].to,u);
low[u]=min(low[u],low[e[i].to]);
if (low[e[i].to]>=dfn[u] && u!=1) p[u]++;
else if (u==1) root++;
}
else low[u]=min(low[u],dfn[e[i].to]);
}
}
int main() {
while (scanf("%d",&n)!=EOF && n) {
for (int i=1;i<=n;i++) head[i]=low[i]=dfn[i]=f[i]=p[i]=0;
int u,v;cnt=root=ind=0;
while (scanf("%d",&u)!=EOF && u)
while (getchar()!='\n') {
scanf("%d",&v);
link(u,v);
}
Tarjan(1,0);
int ans=0;
if (root>1) ans++;
for (int i=2;i<=n;i++) if (p[i]) ans++;
printf("%d\n",ans);
}
return 0;
}

  

【poj1144】 Network的更多相关文章

  1. 【POJ1144】Network(割点)(模板)

    题意:给定一张无向图,求割点个数 思路:感谢CC大神http://ccenjoyyourlife.blog.163.com/的讲解 割点的定义就是某个联通块中删去此点连通性发生变化的的点 有两种割点: ...

  2. 【BZOJ】【1834】【ZJOI2010】Network 网络扩容

    网络流/费用流 这题……我一开始sb了. 第一问简单的最大流…… 第二问是要建费用流的图的……但是是在第一问的最大流跑完以后的残量网络上建,而不是重建…… 我们令残量网络上原有的弧的费用全部为0(因为 ...

  3. 【树形贪心】【UVA1267】Network

    重要意义:复习好久没写的邻接表了. Network, Seoul 2007, LA3902 Consider a tree network with n nodes where the interna ...

  4. 【OpenStack】network相关知识学习

    network 类型 local:通信不跨主机,必须同一网段,主要做单机测试使用: flat:统计可以跨主机,但是需要在同一网段: 每个 flat network 都会独占一个物理网卡 计算节点上 b ...

  5. 【转】[Network] 计算机网络基础知识总结

    阅读目录 1. 网络层次划分 2. OSI七层网络模型 3. IP地址 4. 子网掩码及网络划分 5. ARP/RARP协议 6. 路由选择协议 7. TCP/IP协议 8. UDP协议 9. DNS ...

  6. 【图论】Network of Schools

    [POJ1236]Network of Schools Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 18969   Acc ...

  7. 【leetcode】Network Delay Time

    题目: There are N network nodes, labelled 1 to N. Given times, a list of travel times as directed edge ...

  8. BZOJ 1834 【ZJOI2010】 network 网络扩容

    Description 给定一张有向图,每条边都有一个容量C和一个扩容费用W.这里扩容费用是指将容量扩大1所需的费用.求: 1. 在不扩容的情况下,1到N的最大流: 2. 将1到N的最大流增加K所需的 ...

  9. 【BZOJ3732】 Network Kruskal+倍增lca

    Description 给你N个点的无向图 (1 <= N <= 15,000),记为:1…N. 图中有M条边 (1 <= M <= 30,000) ,第j条边的长度为: d_ ...

随机推荐

  1. 第2章 面向对象的设计原则(SOLID):2_里氏替换原则(LSP)

    2. 里氏替换原则(Liskov Substitution Principle,LSP) 2.1 定义 (1)所有使用基类的地方必须能透明地使用子类替换,而程序的行为没有任何变化(不会产生运行结果错误 ...

  2. Android 中JNI创建实例

    参考文档: http://blog.sina.com.cn/s/blog_a11f64590101924l.html http://www.cnblogs.com/hoys/archive/2010/ ...

  3. 立即执行函数与window.onload作用类似

    (function(){ }()); // 立即执行函数 或者用window.onload=function(){}也可以  

  4. 对window的认识

    首先要明确: 不管是全局的函数还是全局的变量,都是属于window的,例如: a = 12; //全局变量 alert(a) === alert(window.a) function show(){ ...

  5. ruby 元编程

    一 对象模型 kernel Module Kernel.private_instance_methods.grep(/^pr/)   private method 1 如果一个方法接收者不是你自己,一 ...

  6. es安装

    1,安装java(至少1.8) yum install -y java java -version 在/etc/profile追加: JAVA_HOME=/usr/java/jdk1..0_45 PA ...

  7. Linux 网络编程九(select应用--大并发处理)

    //网络编程服务端 /* * 备注:因为客户端代码.辅助方法代码和epoll相同,所以select只展示服务器端代码 */ #include <stdio.h> #include < ...

  8. Linux Linux程序练习十一(网络编程大文件发送UDP版)

    //网络编程发送端--大文件传输(UDP) #include <stdio.h> #include <stdlib.h> #include <string.h> # ...

  9. 后盾网VIP美团网开发(基于HDPHP)(全套38课)

    教程简介 本教程由后盾网讲解,共40节,主要介绍了美团网的开发,从需求分析出发,对商铺的建立.购物流程的构建及订单处理等都做了详细的介绍,非常适合做电子商务开发的朋友和同学参考学习使用,完整教程可以在 ...

  10. [CareerCup] 8.10 Implement a Hash Table 实现一个哈希表

    8.10 Design and implement a hash table which uses chaining (linked lists) to handle collisions. 这道题让 ...