Description

The Suitably Protected Programming Contest (SPPC) is a multi-site contest in which contestants compete at specified sites, which are linked by the Notorious Broken Network (NBN) of two-way links between some pairs of individual sites. There is at most one link directly between any pair of sites and there is no link from a site to itself. Contestants submit their solutions to a judging server to get them tested. The event will use one or more judging servers. Each judging server is located at a contest site and may be accessed directly from that site or through a sequence of linked sites. At any time during the contest, each contestant must have access to at least one judging server. The links between sites are set up in such a way that if all links work properly, it would suffice to operate one judging server. At the other extreme, having each site operate its own judging server would guarantee access even if all of the links failed. The organisers wish to minimise the number of judging servers that they operate, while still maintaining the integrity of the contest. Examination of the NBN’s performance over time reveals some good news. The NBN is reliably unreliable! At any given time, exactly one link is broken (that is, communications cannot travel in either direction on that link). Given this fact, the organisers want you to work out the minimum number of judging servers that must operate so that no matter which link is broken, every contestant still has access to at least one judging server. As they know that they must operate at least one judging server, they ask you to tell them how many extra judging servers they must operate.

Input

The first line of the input contains a single integer S (2 ≤ S ≤ 100 000), which is the number of sites. The sites are numbered from 0 to S − 1. The next S lines describe the sites. Each of these lines starts with an integer l (0 ≤ l < S), which is the number of links that this site has to a site with a larger number. Then follow ‘ integers in ascending order, which are the sites to which those links go. Note that, although links are two-way, they are only mentioned in the lower numbered site’s line. The total number of links is no more than 100 000.

Output

Display the minimum number of extra judging servers the organisers must operate.

Sample Input

4
3 1 2 3
0
0
0

Sample Output

2

给你一个无向图 ,任意删除一条边,
要使得每一个点都能在这个它所在的图里面能到达每一个点,任意两点都有路径 问最少需要几个点才能满足条件
其实就是问这个无向图缩点后度为于1的点有多少个
注意 一开始说了有1个点了,所以要减去1
 #include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
using namespace std; const int maxn = 3e5 + ;
int n, m, u, v, tot, top, cnt, flag;
struct node {
int u, v, next;
} edge[maxn];
int head[maxn], instack[maxn], s[maxn];
int dfn[maxn], low[maxn], belong[maxn];
void init() {
tot = cnt = top = flag = ;
memset(s, , sizeof(s));
memset(head, -, sizeof(head));
memset(dfn, , sizeof(dfn));
memset(instack, , sizeof(instack));
}
void add(int u, int v) {
edge[tot].v = v;
edge[tot].u = u;
edge[tot].next = head[u];
head[u] = tot++;
}
void tarjin(int v, int fa) {
dfn[v] = low[v] = ++flag;
instack[v] = ;
s[top++] = v;
for (int i = head[v] ; i != - ; i = edge[i].next) {
int j = edge[i].v;
if (j == fa) continue;
if (!instack[j]) {
tarjin(j, v);
low[v] = min(low[v], low[j]);
} else if (instack[j] == ) low[v] = min(low[v], dfn[j]);
}
if (dfn[v] == low[v]) {
cnt++;
int t;
do {
t = s[--top];
instack[t] = ;
belong[t] = cnt;
} while(t != v) ;
}
}
int du[maxn];
int main() {
while(scanf("%d", &n) != EOF) {
init();
memset(du, , sizeof(du));
for (int i = ; i <= n ; i++) {
int x, y;
scanf("%d", &x);
while(x--) {
scanf("%d", &y);
y++;
add(i, y);
add(y, i);
}
}
for (int i = ; i <= n ; i++)
if (!instack[i]) tarjin(i, -);
for(int i = ; i <= tot; i += ) {
if(belong[edge[i].u] != belong[edge[i].v]) {
du[belong[edge[i].u]]++;
du[belong[edge[i].v]]++;
}
}
int ans = ;
for (int i = ; i <= cnt ; i++)
if (du[i]==) ans++;
printf("%d\n", max(ans-, ));
}
return ;
}

Extra Judicial Operation的更多相关文章

  1. mysql in 子查询 效率慢 优化(转)

    mysql in 子查询 效率慢 优化(转) 现在的CMS系统.博客系统.BBS等都喜欢使用标签tag作交叉链接,因此我也尝鲜用了下.但用了后发现我想查询某个tag的文章列表时速度很慢,达到5秒之久! ...

  2. iOS消息体系架构详解-融云即时通讯云

    iOS SDK 体系架构 本文档将详细介绍融云的 SDK 产品架构和消息体系,以便于您更深入的了解融云并更快速的开发自己的产品. 融云 SDK 系统架构 IMKit IMKit 的功能主要是封装各种界 ...

  3. Web Reference for a WCF Service has Extra “IdSpecified” Parameter ?

    Question: I created a WCF service that exposed a method that has one paramater: public class Service ...

  4. Exception: Operation xx of contract xx specifies multiple request body parameters to be serialized without any wrapper elements.

    Operation 'CreateProductCodeStock' of contract 'IChileService' specifies multiple request body param ...

  5. RFC 8684---TCP Extensions for Multipath Operation with Multiple Addresses

    https://datatracker.ietf.org/doc/rfc8684/?include_text=1 TCP Extensions for Multipath Operation with ...

  6. 终端mysql Operation not permitted错误解决方案

    前言 前段时间装mysql,就遇到了ln: /usr/bin/mysql: Operation not permitted的错误,网上好多方法都过时了,下边是我的解决方法 原因 这是因为苹果在OS X ...

  7. SVN:Previous operation has not finished; run 'cleanup' if it was interrupted

    异常处理汇总-开发工具  http://www.cnblogs.com/dunitian/p/4522988.html cleanup failed to process the following ...

  8. Mysql Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation '='

    MySQL字符串比较bug: select * from table_a a left join table_b b on a.field_a = b.field_b   error: Illegal ...

  9. TNS-12535: TNS:operation timed out案例解析

    一数据库突然连接不上,在自己电脑上使用SQL Developer也连接不上.立即使用SecureCRT连接上了这台服务器,从下面几个方面检查. 1:检查了数据库的状态是否正常 $ sqlplus / ...

随机推荐

  1. Linux常见文件管理命令

    1.Linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示.(1)目录管理命令——ls:列出指定目录下的内容格式:ls [OPTION]... [FILE]... -a:显示所有文件包 ...

  2. php中==和===的含义及区别

    ===比较两个变量的值和类型:==比较两个变量的值,不比较数据类型. 比如 $a = '123'; $b = 123; $a === $b为假: $a == $b为真: 有些情况下不能使用==,可以使 ...

  3. Python学习笔记:PEP8常用编程规范

    PEP8编码规范是一种非常优秀的编码规范,也得到了Python程序员的普遍认可,如果实践中或者项目中没有统一的编码规范,建议尽量遵循PEP8编码规范,当然如果项目中已经有了自身的编码规范,应当优先遵循 ...

  4. Altium Designer使用5:AD18的DXP在什么地方?

    1.在顶上的菜单栏右击

  5. 吴恩达DeepLearning 第一课第四周随笔

    第四周 4.1深度神经网络符号约定 L=4______(神经网络层数)   4.2 校正矩阵的维数 校正要点:,, dZ,dA,dW,db都与它们被导数(Z,A,W,b)的维数相同 4.3 为什么使用 ...

  6. [Bzoj4408]神秘数(主席树)

    Description 一个可重复数字集合S的神秘数定义为最小的不能被S的子集的和表示的正整数. 例如S={1,1,1,4,13}, 1 = 1 2 = 1+1 3 = 1+1+1 4 = 4 5 = ...

  7. python基础之列表、元组和字典

    列表 列表定义:[]内以逗号分隔,按照索引,存放各种数据类型,每个位置代表一个元素 特性: 1.可存放多个值 2.可修改指定索引位置对应的值,可变 3.按照从左到右的顺序定义列表元素,下标从0开始顺序 ...

  8. 初见spark-04(高级算子)

    今天,这个是spark的高级算子的讲解的最后一个章节,今天我们来介绍几个简单的算子, countByKey val rdd1 = sc.parallelize(List(("a", ...

  9. vue命令集合

    创建vuecli脚手架:npm install -g @vue/cli拉取2的版本:npm install -g @vue/cli-init 创建webpack:npm i webpack@3.12. ...

  10. MyBatis---集合查询(一对多)

    这里的集合查询即一对多的数据联合查询.如一个用户多次登录的信息查询 要实现这样的联合查询需要在用户实体类中添加登录实体类的一个集合属性字段,表中不存在该字段. <resultMap id=&qu ...