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%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。。。确实是的
代码:
- #include<cstdio>
- #include<cstdlib>
- #include<cmath>
- #include<cstring>
- #include<algorithm>
- #include<iostream>
- #include<vector>
- #include<map>
- #include<set>
- #include<queue>
- #include<string>
- #define inf 1000000000
- #define maxn 500
- #define maxm 500+100
- #define eps 1e-10
- #define ll long long
- #define pa pair<int,int>
- #define for0(i,n) for(int i=0;i<=(n);i++)
- #define for1(i,n) for(int i=1;i<=(n);i++)
- #define for2(i,x,y) for(int i=(x);i<=(y);i++)
- #define for3(i,x,y) for(int i=(x);i>=(y);i--)
- #define mod 1000000007
- #define sqr(x) (x)*(x)
- using namespace std;
- inline int read()
- {
- int x=,f=;char ch=getchar();
- while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
- while(ch>=''&&ch<=''){x=*x+ch-'';ch=getchar();}
- return x*f;
- }
- int n,t,k;
- struct rec{double x,y;}a[maxn];
- double c[maxn][maxn],d[maxn][maxn];
- queue<pa>q;
- bool v[maxn][maxn];
- int main()
- {
- freopen("input.txt","r",stdin);
- freopen("output.txt","w",stdout);
- n=read();t=read();k=read();
- for0(i,n)a[i].x=read(),a[i].y=read();
- for0(i,n)for0(j,n)c[i][j]=sqrt(sqr(a[i].x-a[j].x)+sqr(a[i].y-a[j].y));
- for0(i,n)for0(j,k)d[i][j]=inf;
- d[][]=;
- q.push(pa(,));
- while(!q.empty())
- {
- int x=q.front().first,y=q.front().second;q.pop();
- v[x][y]=;
- for1(i,n)
- if(i!=x&&d[x][y]+c[x][i]<d[i][y+])
- {
- d[i][y+]=d[x][y]+c[x][i];
- if(!v[i][y+]){v[i][y+]=;q.push(pa(i,y+));}
- }
- }
- double ans=inf;
- for1(i,n)if(i!=t)ans=min(ans,d[i][k]+c[i][t]);
- printf("%.2f\n",ans);
- return ;
- }
Beta Round #9 (酱油杯noi考后欢乐赛)PLQ的寻宝的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 洛谷---小L和小K的NOIP考后放松赛
链接: https://www.luogu.org/contestnew/show/11805?tdsourcetag=s_pcqq_aiomsg 题解: 没人过的题我就没看 t2: 考虑每个点是朋友 ...
- Codeforces Beta Round #57 (Div. 2)
Codeforces Beta Round #57 (Div. 2) http://codeforces.com/contest/61 A #include<bits/stdc++.h> ...
- Codeforces Beta Round #52 (Div. 2)
Codeforces Beta Round #52 (Div. 2) http://codeforces.com/contest/56 A #include<bits/stdc++.h> ...
- Codeforces Beta Round #46 (Div. 2)
Codeforces Beta Round #46 (Div. 2) http://codeforces.com/contest/49 A #include<bits/stdc++.h> ...
- Codeforces Beta Round #31 (Div. 2, Codeforces format)
Codeforces Beta Round #31 (Div. 2, Codeforces format) http://codeforces.com/contest/31 A #include< ...
随机推荐
- Linux FTP的安装与配置(转)
Linux FTP的安装与配置 ftp安装部分,操作步骤如下: 可以使用yum命令直接安装ftp # yum install vsftpd ftp服务的开启与关闭命令: 开启:# service ...
- jQuery $.each的使用方法
通过jQuery $.each,你可以遍历对象.数组的属性值并进行处理. 使用说明 each函数根据参数的类型实现的效果不完全一致: 1.遍历对象(有附加参数) $.each(Object, func ...
- iOS开发——友盟分享
==========2016-01-29 更新=====刘成利 email:liu_cheng_li@qq.com========== 自己成功集成到公司的项目前,也已做了测试好的友盟分享demo 目 ...
- struts2初印象
第一次写这么正式的文章,如果写的不好的地方,请指出. 今天玩了一下struts2,不过貌似是我被他玩了.简要笔记如下: 一.配置struts2(在eclipse Helios版本下) (1)先创建一个 ...
- 网站开发常用jQuery插件总结(五)滚动条插件nanoscroller
网站在展示信息时,如果信息量过大,解决方法主要有三种.1.分页,将信息分页显示.2.整页显示,但是页面过长,影响浏览体验.3.使用滚动条,而默认滚动条样式太单一,用户体验不友好.所以我们需要美化滚动条 ...
- 关于Hyper-V虚拟机中的vEthernet虚拟网卡不能联网的问题
Hyper-V虚拟机在我电脑里面已经有一年了,当初是因为windows8系统里面需要装Hyper-V,这样才能不让win8死机,就折腾了一整子,结果碰到vEthernet网卡不能联网,网上相关的资料少 ...
- [C#]Task异步操作
1.代码示例 using System; using System.Threading; using System.Threading.Tasks; namespace ConsoleApplicat ...
- HTML5格式化
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...
- QTcpsocket 实现FTP
http://blog.163.com/modingfa_002/blog/static/1109254662013111510358109/ http://baike.baidu.com/link? ...
- 加密你的SQLite
转自王中周的个人博客 关于SQLite SQLite是一个轻量的.跨平台的.开源的数据库引擎,它的在读写效率.消耗总量.延迟时间和整体简单性上具有的优越性,使其成为移动平台数据库的最佳解决方案(如iO ...