hdu 6380
#include<bits/stdc++.h>
#define in(a) scanf("%d",&a)
using namespace std; struct nod
{
int v,next;
}side[]; int head[],cnt,index,fri[]; void add(int u,int v)
{
side[cnt].v=v;
side[cnt].next=head[u];
head[u]=cnt++;
fri[u]++; } int scc[],dfn[],low[],ins[],vis[],stac[],tail; void tarjan(int cur)
{
dfn[cur]=low[cur]=index++;
ins[cur]=;
vis[cur]=;
stac[tail++]=cur;
for(int i=head[cur];i!=-;i=side[i].next)
{
int c=side[i].v;
if(!vis[c])
{
tarjan(c);
low[cur]=min(low[cur],low[c]);
}
else if(ins[c])
low[cur]=min(low[cur],dfn[c]);
}
if(dfn[cur]==low[cur])
{
cnt++;
int v;
do
{
v=stac[tail-];
scc[v]=cnt;
ins[v]=;
tail--;
}while(v!=cur);
}
} int main()
{
int N;
in(N);
while(N--)
{
memset(head,-,sizeof(head));
memset(ins,,sizeof(ins));
memset(vis,,sizeof(vis));
memset(fri,,sizeof(fri));
int n,m,k,x,y;
in(n);in(m);in(k);
cnt=;
for(int i=;i<m;i++)
{
in(x);in(y);
add(x,y);add(y,x);
}
index=;tail=;cnt=;
int maxn=;
for(int i=;i<n;i++)
{
if(!vis[i])
tarjan(i);
maxn=max(maxn,fri[i]);
}
if(maxn+cnt-+k>n-)
printf("%d\n",n-);
else
printf("%d\n",maxn+cnt-+k); }
return ;
}
hdu 6380的更多相关文章
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 4006The kth great number(K大数 +小顶堆)
The kth great number Time Limit:1000MS Memory Limit:65768KB 64bit IO Format:%I64d & %I64 ...
- HDU 1796How many integers can you find(容斥原理)
How many integers can you find Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d ...
- hdu 4481 Time travel(高斯求期望)(转)
(转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pi ...
- HDU 3791二叉搜索树解题(解题报告)
1.题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=3791 2.参考解题 http://blog.csdn.net/u013447865/articl ...
- hdu 4329
problem:http://acm.hdu.edu.cn/showproblem.php?pid=4329 题意:模拟 a. p(r)= R'/i rel(r)=(1||0) R ...
随机推荐
- 【XSY2787】Mythological VII 贪心
题目描述 有两个指针\(l,r\),初始时\(l=r=k\) 给你\(a_1,\ldots,a_n\),你要移动\(l,r\),\(l\)只能每次向左移一个数,\(r\)只能向右移一个数,要求任意时刻 ...
- MT【266】求$a$的范围
已知 $a$ 为常数,函数$f(x)=\dfrac{x}{\sqrt{a-x^2}-\sqrt{1-x^2}}$ 的最小值为$-\dfrac{2}{3}$,则 $a$ 的取值范围_____ 解: 考虑 ...
- #565. 「LibreOJ Round #10」mathematican 的二进制(期望 + 分治NTT)
题面 戳这里,题意简单易懂. 题解 首先我们发现,操作是可以不考虑顺序的,因为每次操作会加一个 \(1\) ,每次进位会减少一个 \(1\) ,我们就可以考虑最后 \(1\) 的个数(也就是最后的和) ...
- 新建WINDOWS服务C#
当前作业环境 Windows8.1 | Visual Studio 2013 一. 建立项目,选择"Windows服务"模板 二. 查看生成的项目,结构很像WinForm的项目,其 ...
- ELK部署详解--kibana
kibana.yml # Kibana is served by a back end server. This setting specifies the port to use.#端口server ...
- luogu4728 双递增序列 (dp)
设f[i][j]表示以i位置为第一个序列的结尾,第一个序列的长度为j,第二个序列的结尾的最小值 那么对于f[i][j],有转移$f[i+1][j+1]=min\{f[i+1][j+1],f[i][j] ...
- [SCOI2010]幸运数字(容斥+爆搜)
在中国,很多人都把6和8视为是幸运数字!lxhgww也这样认为,于是他定义自己的“幸运号码”是十进制表示中只包含数字6和8的那些号码,比如68,666,888都是“幸运号码”!但是这种“幸运号码”总是 ...
- hdu 2594 Simpsons’ Hidden Talents(扩展kmp)
Problem Description Homer: Marge, I just figured out a way to discover some of the talents we weren’ ...
- Spring乱码问题解决方案
请求乱码 GET请求乱码: 原因:请求参数带在url地址上.url地址什么时候解析? tomcat收到请求对url进行编解码(ISO8859-1) 解决方案:在tomcat的8080端口配置出加上 U ...
- codevs1260 快餐问题
题意: 一个套餐需要a个A,b个B,c个C. 你生产一个A需要t1,一个B需要t2,一个C需要t3时间. 你有n台机器.每台每天工作timei时间. 一件物品只能在一个机器上生产. 求你一天最多能生产 ...