题目链接

题意: 给定一个无向图,一个汇集点,问哪一个点是最关键的,如果有多个关键点,输出序号最小的那个。


因为数据量比较小,所以暴力搜索就行,每去掉一个点,寻找和汇集点相连的还剩几个点,以此确定哪个点是关键点。

自己当时没有做出来,主要是以下几个原因:

  • 比赛时过于浮躁,翻译时不细心,没有看出是输出序号最小的点。
  • 把题想的过于复杂,和考点背道而驰。
  • 没有把握好逆向思维,既然要判断有几个点和汇集点相连,就去判断每个点是否和汇集点相连,正确的思路是判断汇集点和哪些点相连,即搜索的出发点是汇集点。

总结:

  • 以后做题时,先去想最朴实无华的暴力求解。
  • 稳住心态尤其重要。

CODE:

  1. #include<cstdio>
  2. #include<cstdlib>
  3. #include<cstring>
  4. #include<string>
  5. #include<cmath>
  6. #include<algorithm>
  7. #include<queue>
  8. #include<stack>
  9. #include<deque>
  10. #include<map>
  11. #include<iostream>
  12. using namespace std;
  13. typedef long long LL;
  14. const double pi=acos(-1.0);
  15. const double e=exp(1);
  16. const int N = 100009;
  17. int con[109][109];
  18. int check[109];
  19. int ans,tar,del,n;
  20. void DFS(int x)
  21. {
  22. int i,p,j;
  23. for(i = 1 ; i <= n; i++)
  24. {
  25. if(i == del || i == tar || i == x)
  26. {
  27. continue;
  28. }
  29. if(con[x][i] && check[i] == 0)
  30. {
  31. ans++;
  32. check[i] = 1;
  33. DFS(i);
  34. }
  35. }
  36. }
  37. int main()
  38. {
  39. int i,p,j,t;
  40. int a,b,m,mid,head,spot;
  41. while(scanf("%d",&n)!=EOF)
  42. {
  43. if(n == 0)
  44. break;
  45. memset(check,0,sizeof(check));
  46. memset(con,0,sizeof(con));
  47. head = 9999;
  48. spot = 1;
  49. scanf("%d",&tar);
  50. scanf("%d",&m);
  51. for(i=1; i<=m;i++)
  52. {
  53. scanf("%d%d",&a,&b);
  54. con[a][b] = con[b][a] = 1;
  55. }
  56. for(i = 1; i <= m; i++)
  57. {
  58. if(i == tar)
  59. continue;
  60. ans = 0;
  61. del = i;
  62. check[tar] = 1;
  63. memset(check,0,sizeof(check));
  64. DFS(tar);
  65. mid = ans;
  66. if(head > mid)
  67. {
  68. head = mid;
  69. spot = i;
  70. }
  71. }
  72. printf("%d\n",spot);
  73. }
  74. return 0;
  75. }

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. UVaLive 7456 Least Crucial Node (并查集+暴力 或者 求割点)

    题意:求标号最小的最大割点.(删除该点后,指定点#sink能到达的点数减少最多). 析:由于不知道要去掉哪个结点,又因为只有100个结点,所以我们考虑用一个暴力,把所有的结点都去一次,然后用并查集去判 ...

  3. C - Least Crucial Node

    题目链接:https://cn.vjudge.net/contest/247936#problem/C 具体大意:给你起点和中点,总点数,边数.求到终点的最小割点. 具体思路:可以用tarjan算法来 ...

  4. babeljs源码

    babel.min.js!function(e,t){"object"==typeof exports&&"object"==typeof mo ...

  5. UVALive - 4108 SKYLINE[线段树]

    UVALive - 4108 SKYLINE Time Limit: 3000MS     64bit IO Format: %lld & %llu Submit Status uDebug ...

  6. UVALive 6145 Version Controlled IDE(可持久化treap、rope)

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

  7. 【暑假】[实用数据结构]UVAlive 3135 Argus

    UVAlive 3135 Argus Argus Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %l ...

  8. 二分+最短路 uvalive 3270 Simplified GSM Network(推荐)

    // 二分+最短路 uvalive 3270 Simplified GSM Network(推荐) // 题意:已知B(1≤B≤50)个信号站和C(1≤C≤50)座城市的坐标,坐标的绝对值不大于100 ...

  9. HDU 4169 UVALive 5741 Wealthy Family

    树形背包.DP递推的思路很简单.... 但是由于节点有15万个,先不论空间复杂度,这样开dp数组 dp[150000+10][300+10],如果初始化是memset(dp,-1,sizeof dp) ...

随机推荐

  1. CentOS-7.x Yum Repo Mirror

    一. 环境 1.1 主机信息 主机 OS Storage 备注 100.64.140.101 centos 7.6 /dev/sdb > 100GB 1.selinux disable; 2.放 ...

  2. Node.js Event Loop 的理解 Timers,process.nextTick()

    写这篇文章的目的是将自己对该文章的理解做一个记录,官方文档链接The Node.js Event Loop, Timers, and process.nextTick() 文章内容可能有错误理解的地方 ...

  3. “Linux内核分析”实验三报告

    构造一个简单的Linux系统 张文俊+原创作品转载请注明出处+<Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-10000290 ...

  4. Alpha版本总结

    Alpha版本总结 General Questions a)     What went well?  Why? 成功之处:界面设计简洁,功能吸引用户. 原因:铁道大学学生上自习不方便,没有固定的教室 ...

  5. jieba分词学习

    具体项目在githut里面: 应用jieba库分词 1)利用jieba分词来统计词频: 对应文本为我们队伍的介绍:jianjie.txt: 项目名称:碎片 项目描述:制作一个网站,拾起日常碎片,记录生 ...

  6. grunt入门讲解1:grunt的基本概念和使用

    Grunt和 Grunt 插件是通过 npm 安装并管理的,npm是 Node.js 的包管理器. Grunt 0.4.x 必须配合Node.js >= 0.8.0版本使用.老版本的 Node. ...

  7. Ubuntu忘记MySQL密码重设方法

    ====================忘了mysql密码,从网上找到的解决方案记录在这里==================== 结束当前正在运行的mysql进程 # /etc/init.d/mys ...

  8. JSONP使用及注意事项小结

    什么是JSONP 三句话总结: 概念:JSONP(JSON with Padding)是JSON的一种"使用模式". 目的:用于解决主流浏览器的跨域数据访问的问题. 原理:利用 & ...

  9. BZOJ 3171 循环格(费用流)

    题意 一个循环格就是一个矩阵,其中所有元素为箭头,指向相邻四个格子.每个元素有一个坐标(行,列),其中左上角元素坐标为(0,0).给定一个起始位置(r,c),你可以沿着箭头防线在格子间行走.即如果(r ...

  10. mininet invalid literal for int() with base 10: 'cpu.cfs_period_us:'

    问题产生原因:内核编译时没有加入 CONFIG_CFS_BANDWIDTH 选项 http://www.haifux.org/lectures/299/netLec7.pdf https://mail ...