题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=5478


题意:有n个点,m条边,给出点S(1~n中的某个点)。除了S点之外的n-1个点中的一个如果失效,那么可能会影响到若干个点和S的连通性。现在要找一个点p,使得p失效后使得点和S不连通的数量最大,在此基础上p的标号越小。


思路:枚举失效n-1个点,每次做一遍并查集,检查有多少点会失效。然后取最大值即可。


#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <utility>
using namespace std;#define rep(i,j,k) for (int i=j;i<=k;i++)
#define Rrep(i,j,k) for (int i=j;i>=k;i--)#define Clean(x,y) memset(x,y,sizeof(x))
#define LL long long
#define ULL unsigned long long
#define inf 0x7fffffff
#define mod 100000007#define mp make_pair
#define fi first
#define se second#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define mid int m=(l+r)>>1
const int maxn = 110;int n,m,st;int x[maxn*maxn];
int y[maxn*maxn];
int k[maxn];int father[maxn];int getfather(int x)
{return x==father[x]?x:father[x] = getfather(father[x]);
}void init()
{scanf("%d",&st);scanf("%d",&m);rep(i,1,m) scanf("%d%d",&x[i],&y[i]);Clean(k,0);
}void unio( int a , int b )
{int fa = getfather(a);int fb = getfather(b);if ( fa != fb ){father[fa] = fb;}
}
void solve()
{rep(i,1,n){if ( i == st ) continue;rep(j,1,n) father[j] = j;rep(j,1,m)if ( x[j] != i && y[j] != i )unio( x[j] , y[j] );rep(j,1,n)if ( j != i && getfather(j) != getfather(st) ) k[i]++;}int ans,M = 0;rep(i,1,n)if ( k[i] > M ){M = k[i];ans = i;}printf("%d\n",ans);
}int main()
{while( scanf("%d",&n) == 1 ){if ( !n ) break;init();solve();}return 0;
}

UVALive 7456 Least Crucial Node相关推荐

  1. UVALive 7456 Least Crucial Node (并查集)

    Least Crucial Node 题目链接: http://acm.hust.edu.cn/vjudge/contest/127401#problem/C Description http://7 ...

  2. 【割点 dfs】UVALive - 7456 Least Crucial Node

    Problem Description 给你n,s,m分别代表n个点,s为特殊点,m条边.让你求去掉那个点?使得其他点不能到达s点的点最多.如果存在割点,一样多的.输出编号最小的. 思路: 割点的条件 ...

  3. UVALive - 7456 Least Crucial Node ( dfs + set )

    直接暴力求解,枚举每个点, dfs 求解对后面影响的点的个数 #include <iostream> #include <cstdio> #include <string ...

  4. UVALive Problem 7456 Least Crucial Node——Regionals 2015 :: Asia - Taipei

    此文章可以使用目录功能哟↑(点击上方[+])  UVALive Problem 7456 Least Crucial Node Accept: 0    Submit: 0 Time Limit: 3 ...

  5. LA 7456 Least Crucial Node

    题意:有一个联通图G(V,E), |V| <= 100,其中一个vertex是源点,即sink,由sink沿图向其他点发送信息.当你disable了一个点(非sink),阻断了通过该点的信息传输 ...

  6. Least Crucial Node UVALive - 7456

    AC代码(找与k联通的点最少的那个node, dfs) Select Code #include <iostream> #include <bits/stdc++.h> #de ...

  7. Least Crucial Node UVALive - 7456 【】

    题目要求:求联通图   序号最小的最大割点. 解决方案: 枚举每一个点(除了起点),每一次从头开始搜. 比较出 去掉哪个点 时 能连的最少 一些新stl 知识点 bitset : 百度百科 auto ...

  8. 吾爱破解培训第一课作业密码_如何实现您的第一个无密码登录系统

    吾爱破解培训第一课作业密码 You may have heard that there are 360 Million Reasons to Destroy All Passwords and tha ...

  9. The UVALIVE 7716 二维区间第k小

    The UVALIVE 7716 二维区间第k小 /** 题意:给一个n * n的矩阵,有q个查询每次查询r,c,s,k表示已(r,c)为右上角 大小为s的正方形中 第k小的元素n <= 250 ...

最新文章

  1. 使用autoconf完成编译配置
  2. svnadmin: e000002: 无法创建最上层目录_JFolder::create: 无法创建目录
  3. Android中解析XML
  4. python中类型错误、计数不采用关键字的错误怎么改_Learning/Python-面试问题.md at master · yxxyyx1314/Learning · GitHub...
  5. boost::hana::test::TestRing用法的测试程序
  6. Ubuntu 16.04 LTS apt-get connect refuse Unable to connect to 127.0.0.1:1080
  7. python中import sys_python import sys出错怎么办
  8. 移动APP开发工作笔记001---Hbuilder连接苹果手机
  9. Android教程 第五章 常用UI界面控件
  10. fiddler 对https支持
  11. 【优化算法】水基湍流优化算法(TFWO)【含Matlab源码 1467期】
  12. C51单片机,点亮小灯的入门级教程
  13. 怎么更改自己IP地址 切换电脑本机IP软软件哪个好用
  14. LM393低功耗双电压比较器参数、引脚、应用详解
  15. 如何做抖音小程序赚钱?抖音小程序怎么赚钱?抖音最简单的赚钱方式
  16. [转]库存那些事儿_4_收货
  17. kali网络问题解决办法
  18. 【慕课网】人工智能-语音入门|公开课知识整理
  19. InetAddress.getByName背后发生了什么
  20. mysql命令行不支持中文_解决MySQL命令行不支持中文的问题

热门文章

  1. Mysql8.0下载(网盘云盘)
  2. 二元关系的复合、集合幂集的包含关系是格的证明、逻辑相等与划分
  3. 【数据结构】--队列之循环队列
  4. 移动端名片识别SDK
  5. 详解视频中动作识别模型与代码实践
  6. Pyspark回归--IsotonicRegression
  7. UOJ #11.【UTR #1】ydc的大树 题解
  8. 【题解】曼哈顿模拟赛(洛谷)
  9. vo、dto、bo、do、po的概念理解以及与controller、service、dao层的对应关系
  10. 年薪30W+的IC验证工程师究竟是做什么的?一文为你讲解清楚