LightOJ 1063 Ant Hills
Ant Hills
This problem will be judged on LightOJ. Original ID: 1063
64-bit integer IO format: %lld Java class name: Main
After many years of peace, an ant-war has broken out.
In the days leading up to the outbreak of war, the ant government devoted a great deal of resources toward gathering intelligence on ant hills. It discovered the following:
- The ant empire has a large network of ant-hills connected by bidirectional tracks.
- It is possible to send a message from any ant hill to any other ant hill.
Now you want to stop the war. Since they sometimes attack your house and disturb you quite a lot. So, you have made a plan. You have a gun which can destroy exactly one ant-hill. So, you want to hit an ant hill if it can stop at least two other ant hills passing messages between them. Now you want the total number of ant hills you may choose to fire.
Input
Input starts with an integer T (≤ 20), denoting the number of test cases.
Each test case contains a blank line and two integers n (1 ≤ n ≤ 10000), m (1 ≤ m ≤ 20000). n denotes the number of ant hills and m denotes the number of bi-directional tracks. Each of the next m lines will contain two different integers a b (1 ≤ a, b ≤ n) denoting that there is a track between a and b.
Output
For each case, print the case number and the total number of ant hills you may choose to fire.
Sample Input
2
5 4
2 1
1 3
5 4
4 1
3 3
1 2
2 3
1 3
Sample Output
Case 1: 2
Case 2: 0
Source
#include <bits/stdc++.h>
using namespace std;
const int maxn = ;
struct arc {
int to,next;
arc(int x = ,int y = -) {
to = x;
next = y;
}
} e[];
int head[maxn],dfn[maxn],low[maxn];
int tot,idx,ans,n,m;
bool vis[maxn];
void add(int u,int v) {
e[tot] = arc(v,head[u]);
head[u] = tot++;
e[tot] = arc(u,head[v]);
head[v] = tot++;
}
void tarjan(int u,int fa) {
dfn[u] = low[u] = ++idx;
int son = ;
for(int i = head[u]; ~i; i = e[i].next) {
if(!dfn[e[i].to]) {
tarjan(e[i].to,u);
low[u] = min(low[u],low[e[i].to]);
son++;
if(!vis[u]&&(fa == - && son > || fa != - && low[e[i].to] >= dfn[u])) {
vis[u] = true;
ans++;
}
} else low[u] = min(low[u],dfn[e[i].to]);
}
}
int main() {
int T,u,v,cs = ;
scanf("%d",&T);
while(T--) {
scanf("%d %d",&n,&m);
memset(head,-,sizeof(head));
memset(dfn,,sizeof(dfn));
memset(low,,sizeof(low));
memset(vis,false,sizeof(vis));
ans = tot = ;
for(int i = ; i < m; ++i) {
scanf("%d %d",&u,&v);
add(u,v);
}
tarjan(,-);
printf("Case %d: %d\n",cs++,ans);
}
return ;
}
LightOJ 1063 Ant Hills的更多相关文章
- lightoj 1063 求割点
题目链接:http://lightoj.com/volume_showproblem.php?problem=1063 #include<cstdio> #include<cstri ...
- 【lightoj-1063】Ant Hills(求割点)
求割点模板题 #include <bits/stdc++.h> using namespace std; const int N = 10004; int dfn[N], low[N]; ...
- lightoj刷题日记
提高自己的实力, 也为了证明, 开始板刷lightoj,每天题量>=1: 题目的类型会在这边说明,具体见分页博客: SUM=54; 1000 Greetings from LightOJ [简单 ...
- Jenkins 安装的HTML Publisher Plugin 插件无法展示ant生成的JunitReport报告
最近在做基于jenkins ant junit 的测试持续集成,单独ant junit生成的junitreport报告打开正常,使用Jenkins的HTML Publisher Plugin 插件无 ...
- React中使用Ant Table组件
一.Ant Design of React http://ant.design/docs/react/introduce 二.建立webpack工程 webpack+react demo下载 项目的启 ...
- [Ant]Ant简易教程
前言 Apache Ant,是一个将软件编译.测试.部署等步骤联系在一起加以自动化的一个工具,大多用于Java环境中的软件开发.由Apache软件基金会所提供. Ant是纯Java语言编写的,所以具有 ...
- jenkins / ant / jmeter 持续集成接口自动化
1. 将 jmeter 脚本放在/var/lib/jenkins/workspace/Jmeter_auto/jmxpath路径下 2. 点击http://jk.facebank.net.cn/job ...
- Maven与Ant比较
Maven与Ant比较 0 « 上一篇:Jenkins学习三:介绍一些Jenkins的常用功能» 下一篇:Jenkins学习四:Jenkins 邮件配置 posted @ 2015-03-25 16: ...
- 一.Jmeter+Ant+Jenkins搭建持续集成接口性能自动化测试
微创新作品信息 1)微创新作品描述 A.为什么诞生: 1. 接口测试是测试系统组件间接口的一种测试.接口测试主要用于检测外部系统与系统之间以及内部各个子系统之间的交互点.测试的重点是要检查数据的交换, ...
随机推荐
- navigator.mediaDevices.getUserMedia
navigator.mediaDevices.getUserMedia: 作用:为用户提供直接连接摄像头.麦克风的硬件设备的接口 语法: navigator.mediaDevices.getUserM ...
- GenIcam标准关键词整理
1.<?xml> 版本信息和编码方式 IntSwissKnife 需计算和判断的节点 MaskedIntReg 需查询的节点 2.<RegisterDescription> 寄 ...
- android 选取部分 log 的两种方法
Grep多个条件: android logcat -v time | grep -e A -e B 选取多个android log tag: android logcat -v time -s TAG ...
- To new is C++; To malloc is C; To mix them is sin (混淆C++中的new和C中的malloc是一种犯罪)
Introduction One of the most common questions that get asked during interviews for C++ programmers i ...
- js插件---图片裁剪photoClip
js插件---图片裁剪photoClip 一.总结 一句话总结:页面裁剪图片得到base64格式的图片数据,然后把这个数据通过ajax上传给服务器,服务器将base64图片数据解析成图片并且保存到服务 ...
- 3.AngularJS-过滤器
转自:https://www.cnblogs.com/best/p/6225621.html 二.过滤器 使用过滤器格式化数据,变换数据格式,在模板中使用一个插值变量.语法格式如下: {{ expre ...
- Concurrent.Thread.js
(function(){ if ( !this.Data || (typeof this.Data != 'object' && typeof this.Data != 'functi ...
- 如何在Centos官网下载所需版本的Centos——靠谱的Centos下载教程
很多小伙伴不知道对应版本的Centos怎么下载,最近小编整理了一份Centos详细的下载教程,希望小伙伴们不在为下不到对应版本的Centos而苦恼. 1.进入Centos官网:https://www. ...
- Vim使用心得总结
基本快捷键 v 进入可视模式 i / a 光标前/后插入模式 I / A 行首/末插入模式 Crtl+c 进入命令模式 Crtl+v 进入块可视模式 Q 进入EX模式 gh 进入选择模式 u 撤销 U ...
- python + eclipse + django + postgresql 开发网站(二)
引用与参考 http://www.cnblogs.com/lanxuezaipiao/p/3283932.html python2.7 django1.6 1.新建Django项目