题目:http://www.contesthunter.org/contest/Beta%20Round%20%EF%BC%839%20%28%E9%85%B1%E6%B2%B9%E6%9D%AFnoi%E8%80%83%E5%90%8E%E6%AC%A2%E4%B9%90%E8%B5%9B%29/PLQ%E7%9A%84%E5%AF%BB%E5%AE%9D

题解:看了题目觉得分层图SPFA很好想于是就写了,然后A了。

看标程发现也可以DP。。。确实是的

代码:

  1. #include<cstdio>
  2.  
  3. #include<cstdlib>
  4.  
  5. #include<cmath>
  6.  
  7. #include<cstring>
  8.  
  9. #include<algorithm>
  10.  
  11. #include<iostream>
  12.  
  13. #include<vector>
  14.  
  15. #include<map>
  16.  
  17. #include<set>
  18.  
  19. #include<queue>
  20.  
  21. #include<string>
  22.  
  23. #define inf 1000000000
  24.  
  25. #define maxn 500
  26.  
  27. #define maxm 500+100
  28.  
  29. #define eps 1e-10
  30.  
  31. #define ll long long
  32.  
  33. #define pa pair<int,int>
  34.  
  35. #define for0(i,n) for(int i=0;i<=(n);i++)
  36.  
  37. #define for1(i,n) for(int i=1;i<=(n);i++)
  38.  
  39. #define for2(i,x,y) for(int i=(x);i<=(y);i++)
  40.  
  41. #define for3(i,x,y) for(int i=(x);i>=(y);i--)
  42.  
  43. #define mod 1000000007
  44. #define sqr(x) (x)*(x)
  45.  
  46. using namespace std;
  47.  
  48. inline int read()
  49.  
  50. {
  51.  
  52. int x=,f=;char ch=getchar();
  53.  
  54. while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
  55.  
  56. while(ch>=''&&ch<=''){x=*x+ch-'';ch=getchar();}
  57.  
  58. return x*f;
  59.  
  60. }
  61. int n,t,k;
  62. struct rec{double x,y;}a[maxn];
  63. double c[maxn][maxn],d[maxn][maxn];
  64. queue<pa>q;
  65. bool v[maxn][maxn];
  66.  
  67. int main()
  68.  
  69. {
  70.  
  71. freopen("input.txt","r",stdin);
  72.  
  73. freopen("output.txt","w",stdout);
  74.  
  75. n=read();t=read();k=read();
  76. for0(i,n)a[i].x=read(),a[i].y=read();
  77. for0(i,n)for0(j,n)c[i][j]=sqrt(sqr(a[i].x-a[j].x)+sqr(a[i].y-a[j].y));
  78. for0(i,n)for0(j,k)d[i][j]=inf;
  79. d[][]=;
  80. q.push(pa(,));
  81. while(!q.empty())
  82. {
  83. int x=q.front().first,y=q.front().second;q.pop();
  84. v[x][y]=;
  85. for1(i,n)
  86. if(i!=x&&d[x][y]+c[x][i]<d[i][y+])
  87. {
  88. d[i][y+]=d[x][y]+c[x][i];
  89. if(!v[i][y+]){v[i][y+]=;q.push(pa(i,y+));}
  90. }
  91. }
  92. double ans=inf;
  93. for1(i,n)if(i!=t)ans=min(ans,d[i][k]+c[i][t]);
  94. printf("%.2f\n",ans);
  95.  
  96. return ;
  97.  
  98. }

Beta Round #9 (酱油杯noi考后欢乐赛)PLQ的寻宝的更多相关文章

  1. Beta Round #9 (酱油杯noi考后欢乐赛)PLQ和他的小伙伴们

    题目:http://www.contesthunter.org/contest/Beta%20Round%20%EF%BC%839%20%28%E9%85%B1%E6%B2%B9%E6%9D%AFno ...

  2. Beta Round #9 (酱油杯noi考后欢乐赛)乌鸦喝水

    题目:http://www.contesthunter.org/contest/Beta%20Round%20%EF%BC%839%20%28%E9%85%B1%E6%B2%B9%E6%9D%AFno ...

  3. Beta Round #9 (酱油杯noi考后欢乐赛)随机数生成器

    题目:http://www.contesthunter.org/contest/Beta%20Round%20%EF%BC%839%20%28%E9%85%B1%E6%B2%B9%E6%9D%AFno ...

  4. Beta Round #9 (酱油杯noi考后欢乐赛)最大伤害

    题目:http://www.contesthunter.org/contest/Beta%20Round%20%EF%BC%839%20%28%E9%85%B1%E6%B2%B9%E6%9D%AFno ...

  5. 洛谷---小L和小K的NOIP考后放松赛

    链接: https://www.luogu.org/contestnew/show/11805?tdsourcetag=s_pcqq_aiomsg 题解: 没人过的题我就没看 t2: 考虑每个点是朋友 ...

  6. Codeforces Beta Round #57 (Div. 2)

    Codeforces Beta Round #57 (Div. 2) http://codeforces.com/contest/61 A #include<bits/stdc++.h> ...

  7. Codeforces Beta Round #52 (Div. 2)

    Codeforces Beta Round #52 (Div. 2) http://codeforces.com/contest/56 A #include<bits/stdc++.h> ...

  8. Codeforces Beta Round #46 (Div. 2)

    Codeforces Beta Round #46 (Div. 2) http://codeforces.com/contest/49 A #include<bits/stdc++.h> ...

  9. Codeforces Beta Round #31 (Div. 2, Codeforces format)

    Codeforces Beta Round #31 (Div. 2, Codeforces format) http://codeforces.com/contest/31 A #include< ...

随机推荐

  1. Linux FTP的安装与配置(转)

    Linux FTP的安装与配置   ftp安装部分,操作步骤如下: 可以使用yum命令直接安装ftp # yum install vsftpd ftp服务的开启与关闭命令: 开启:# service  ...

  2. jQuery $.each的使用方法

    通过jQuery $.each,你可以遍历对象.数组的属性值并进行处理. 使用说明 each函数根据参数的类型实现的效果不完全一致: 1.遍历对象(有附加参数) $.each(Object, func ...

  3. iOS开发——友盟分享

    ==========2016-01-29 更新=====刘成利 email:liu_cheng_li@qq.com========== 自己成功集成到公司的项目前,也已做了测试好的友盟分享demo 目 ...

  4. struts2初印象

    第一次写这么正式的文章,如果写的不好的地方,请指出. 今天玩了一下struts2,不过貌似是我被他玩了.简要笔记如下: 一.配置struts2(在eclipse Helios版本下) (1)先创建一个 ...

  5. 网站开发常用jQuery插件总结(五)滚动条插件nanoscroller

    网站在展示信息时,如果信息量过大,解决方法主要有三种.1.分页,将信息分页显示.2.整页显示,但是页面过长,影响浏览体验.3.使用滚动条,而默认滚动条样式太单一,用户体验不友好.所以我们需要美化滚动条 ...

  6. 关于Hyper-V虚拟机中的vEthernet虚拟网卡不能联网的问题

    Hyper-V虚拟机在我电脑里面已经有一年了,当初是因为windows8系统里面需要装Hyper-V,这样才能不让win8死机,就折腾了一整子,结果碰到vEthernet网卡不能联网,网上相关的资料少 ...

  7. [C#]Task异步操作

    1.代码示例 using System; using System.Threading; using System.Threading.Tasks; namespace ConsoleApplicat ...

  8. HTML5格式化

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...

  9. QTcpsocket 实现FTP

    http://blog.163.com/modingfa_002/blog/static/1109254662013111510358109/ http://baike.baidu.com/link? ...

  10. 加密你的SQLite

    转自王中周的个人博客 关于SQLite SQLite是一个轻量的.跨平台的.开源的数据库引擎,它的在读写效率.消耗总量.延迟时间和整体简单性上具有的优越性,使其成为移动平台数据库的最佳解决方案(如iO ...