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< ...
随机推荐
- windows下能读写linux分区的软件 转
1. ext2ifs 这个工具与explore2fs都是John Newbigin使用Delphi写的,explore2fs Copyright (C) 2000,Ext2IFS v0.3 Copyr ...
- #ifndef#define#endif的用法
在网上看到了感觉作者总结得很好,作者辛苦了! #ifndef#define#endif的用法 文件中的#ifndef 头件的中的#ifndef,这是一个很关键的东西.比如你有两个C文件,这两个C文件都 ...
- dbforge studio for mysql 怎样破解
下载好dbforge studio压缩包有两个exe,dbforge.studio.for.mysql.6.0.315-loader.exe ,和dbforgemysql.exe,安装后目录在C:\P ...
- iOS开发——常用字符串string相关方法和处理
(持续更新中……) 1,四舍五入 2,剔除字符 3,拼接字符 4,字符个数和长度 5,字符串的比较 6,字符串的范围 7,字符串转Number类型
- OC 消息传递机制
消息传递(message passing)的概念是Smalltalk语言的核心原则之一,有时Smalltalk和Objective-C被称为面向消息的语言,通常“消息”一词的含义和“方法”是相同的. ...
- 类库探源——System.Configuration 配置信息处理
按照MSDN描述 System.Configuration 命名空间 包含处理配置信息的类型 本篇文章主要两方面的内容 1. 如何使用ConfigurationManager 读取AppSetting ...
- C# Unix时间戳转换为时间
在做一些接口的时候,比如返回数据中有一个时间的属性,它的值是使用Unix时间戳表示的,当我们处理它(保存到本地或者格式化前台展示)时需要转换成日期时间,在此就需要根据时间戳转换为日期时间 (注:Uni ...
- 原生js的数组除重复
js对数组的操作在平常的项目中也会遇到,除去一些增加,或者减少的操作外,还有一个比较重要的操作就是数组的除重,通过数组的除重,我们可以将一个数组中存在的多个重复的数组进行清理,只留下不重复的.另外下面 ...
- Spring配置,JDBC数据源及事务
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...
- Linux常用(持续更新)
1. scp ./bcec_computernode_check.sh root@10.254.3.1:/tmp 2. # uname -a # cat /proc/version # cat /e ...