bzoj 4749: [Usaco2016 Dec]Moocast dfs
来源:互联网 发布:c语言单链表反转 编辑:程序博客网 时间:2024/06/07 04:45
→题目链接←
很水的dfs题
n^2的dfs,把每个点都当作起点跑一遍,最后取max
代码:
#include<iostream>#include<cstdio>#include<cmath>#include<cstring>using namespace std;struct node{int x,y,p;};int n;node a[220];bool f[220];int ans=0;double cal(int x,int y){double d=sqrt((a[x].x-a[y].x)*(a[x].x-a[y].x)*1.0+(a[x].y-a[y].y)*(a[x].y-a[y].y)*1.0);return d;}int dfs(int x){f[x]=true;int sum=1;for(int i=0; i<n; i++){if(f[i] || x==i)continue;if(cal(i,x)<=a[x].p*1.0)sum+=dfs(i);}return sum;}int main(){scanf("%d",&n);for(int i=0; i<n; i++)scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].p);for(int i=0; i<n; i++){memset(f,0,sizeof(f));ans=max(ans,dfs(i));}printf("%d\n",ans);return 0;}
阅读全文
0 0
- bzoj 4749: [Usaco2016 Dec]Moocast dfs
- BZOJ 4747-4749题解 Usaco2016 Dec
- bzoj 4742 [Usaco2016 Dec]Team Building
- bzoj 4746 [Usaco2016 Dec]Lasers and Mirrors
- BZOJ 4748: [Usaco2016 Dec]Cities and States
- BZOJ 4742 [Usaco2016 Dec]Team Building 动态规划
- BZOJ 4742: [Usaco2016 Dec]Team Building ——DP
- bzoj4742 [Usaco2016 Dec] -- DP
- bzoj 4581: [Usaco2016 Open]Field Reduction (dfs)
- 【bzoj 4581】[Usaco2016 Open]Field Reduction(dfs)
- [bzoj4742][Usaco2016 Dec]Team Building
- 【bzoj4742】[Usaco2016 Dec]Team Building
- bzoj4747 [Usaco2016 Dec]Counting Haybales
- bzoj4742 [Usaco2016 Dec]Team Building
- |BZOJ 1648|DFS|[Usaco2006 Dec]Cow Picnic 奶牛野餐
- bzoj 1673: [Usaco2005 Dec]Scales 天平(DFS)
- BZOJ 4580: [Usaco2016 Open]248
- bzoj 4580: [Usaco2016 Open]248
- JavaScript正则表达式
- HashMap
- 35、concurrent.futures模块与协程
- 主席树的不同建树方式
- 【Redis源码剖析】
- bzoj 4749: [Usaco2016 Dec]Moocast dfs
- 从头开始学算法:考研机试题练习(C/C++)--基础知识
- Java 反射
- 关于前滚(roll forward)和回滚(roll back)
- 同学推荐的机器学习资料
- 找出数组中只出现一次的两个数
- 【python】pip安装报错UnicodeDecodeError: 'ascii' codec can't decode byte 0xce in position 7: ordinal not i
- Unity2D入门手册
- springcache使用笔记002_注释驱动的 Spring cache 按条件查询