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. 接口测试是测试系统组件间接口的一种测试.接口测试主要用于检测外部系统与系统之间以及内部各个子系统之间的交互点.测试的重点是要检查数据的交换, ...
随机推荐
- POJ-1456 Supermarket 贪心问题 有时间限制的最小化惩罚问题
题目链接:https://cn.vjudge.net/problem/POJ-1456 此题与HDU-1789完全是一道题 题意 有N件商品,分别给出商品的价值和销售的最后期限,只要在最后日期之前销售 ...
- 帆软FineBI试用
FineBI是帆软软件有限公司推出的一款商业智能(Business Intelligence)产品,FineBI的本质是通过分析企业已有的信息化数据,帮助企业发现并解决存在的问题,预测模拟企业将来的发 ...
- 【Codeforces Round #422 (Div. 2) D】My pretty girl Noora
[题目链接]:http://codeforces.com/contest/822/problem/D [题意] 有n个人参加选美比赛; 要求把这n个人分成若干个相同大小的组; 每个组内的人数是相同的; ...
- Java定时器TimeTask
package com.alan.timer; import java.util.Calendar;import java.util.Date;import java.util.Timer;impor ...
- modSecurity规则学习(六)——检测模式
传统检测模式-自主规则 传统检测模式所有规则都是“闭环”的模式.就像HTTP本身一样,单独的规则是无状态的.这意味着规则之间不共享信息,每个规则都没有关于任何先前规则匹配的信息.它仅使用其当前的单个规 ...
- 如何保证对象线程内唯一:数据槽(CallContext)
CallContext 是类似于方法调用的线程本地存储区的专用集合对象,并提供对每个逻辑执行线程都唯一的数据槽.数据槽不在其他逻辑线程上的调用上下文之间共享.当 CallContext 沿执行代码路径 ...
- Linux企业应用--RHAS 2.1 下安装中文 Lotus Domino R 6.5 图解
原文请到ftp.jms165.com下载,是用上传用户 (RHAS3+ksnapshot+OperOff ...
- 紫书 例题 9-12 UVa 12186 (树形dp)
这道题还是比较简单的,对于当前节点,算出每个儿子需要的人数 然后再算出当前节点需要多少个人数,然后排个序加上去就好了. #include<cstdio> #include<vecto ...
- 小米开源便签Notes-源码研究(1)-导出功能整体思路
NotesListActivity是入口Activity. 响应菜单事件,我的手机是"左键菜单".如果菜单项的ID是"R.id.menu_export_text" ...
- Android学习总结(2)——App客户端与服务器交互中的token
学习Token Token是什么? Token是服务端生成的一串字符串,以作客户端进行请求的一个令牌,当第一次登录后,服务器生成一个Token便将此Token返回给客户端,以后客户端只需带上这个Tok ...