[USACO09JAN]最好的地方Best Spot
OJ题号:洛谷2935
思路:Floyd
#pragma GCC optimize ("O3")
#include<cstdio>
#include<cctype>
#define inf 0x7fffffff>>1
inline int min(const int a,const int b) {
return a<b?a:b;
}
inline int getint() {
int ch;
while(!isdigit(ch=getchar()));
int x=ch^'';
while(isdigit(ch=getchar())) x=((x+(x<<))<<)+(ch^'');
return x;
}
int main() {
int p=getint(),F=getint(),C=getint();
int f[F];
for(int i=;i<F;i++) {
f[i]=getint();
}
int c[p+][p+];
for(int i=;i<=p;i++) {
for(int j=;j<=p;j++) {
c[i][j]=(i==j)?:inf;
}
}
for(int i=;i<C;i++) {
int a=getint(),b=getint(),t=getint();
c[b][a]=c[a][b]=t;
}
for(int k=;k<=p;k++) {
for(int i=;i<=p;i++) {
for(int j=;j<=p;j++) {
c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
}
}
}
int ans,mmin=inf;
for(int i=;i<=p;i++) {
int tmp=;
for(int j=;j<F;j++) {
tmp+=c[i][f[j]];
}
if(tmp<mmin) {
ans=i;
mmin=tmp;
}
}
printf("%d\n",ans);
return ;
}
[USACO09JAN]最好的地方Best Spot的更多相关文章
- 洛谷——P2935 [USACO09JAN]最好的地方Best Spot
P2935 [USACO09JAN]最好的地方Best Spot 题目描述 Bessie, always wishing to optimize her life, has realized that ...
- $P2935 [USACO09JAN]最好的地方Best Spot$
P2935 [USACO09JAN]最好的地方Best Spot Floyd的水题(黄题) 海星. 这可能是我第一道发的Floyd的博客 inline void Floyd(){ ;k<=n;k ...
- 洛谷 P2935 [USACO09JAN]最好的地方Best Spot
题目描述 Bessie, always wishing to optimize her life, has realized that she really enjoys visiting F (1 ...
- Luogu P2935 最好的地方Best Spot
Luogu P2935 最好的地方Best Spot 这道题就是一道近乎裸的Floyd,因为数据很小,所以用领接表存图就可以了. #include<bits/stdc++.h> #defi ...
- URAL 1934 Black Spot(最短路)
Black Spot Time limit: 1.0 secondMemory limit: 64 MB Bootstrap: Jones's terrible leviathan will find ...
- spot 5、ALOS监督分类波段组成
spot 5监督分类RGB:412 ALOS分类波段RGB:432
- Spot light工具集
Spot light on UNIX 安装没什么问题 Spot light on Oracle 必须安装32位的客户端,不然搞死你 两者的界面都是吊炸天啊
- BZOJ3394: [Usaco2009 Jan]Best Spot 最佳牧场
3394: [Usaco2009 Jan]Best Spot 最佳牧场 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 11 Solved: 9[Sub ...
- UVA 141 The Spot Game 斑点游戏。。
The Spot Game The game of Spot is played on an NxN board as shown below for N = 4. During the game ...
随机推荐
- shell 排除目录
1.新建文件 exclude.txt,在文件中写需要排除的目录(只需要目录名称,不需要路径) 2.--exclude-from='/data/www/vhosts/git_track/git-shel ...
- Html页面添加百度地图
1.进入百度地图开放平台 http://lbsyun.baidu.com/ 2.进入右上角的 “API控制台” 在这里创建应用 并 获取密钥 3.进入 如下地址 创建地图 http://api.m ...
- 【转】asp.net Core 系列【一】——创建Web应用
ASP.NET Core 中的 Razor 页面介绍 Razor 页面是 ASP.NET Core MVC 的一个新功能,它可以使基于页面的编码方式更简单高效. 若要查找使用模型视图控制器方法的教程, ...
- Java+selenium之WebDriver的cookie,等待等高级操作(五)
1. 操作cookie // 增加一个 name = "name",value="value" 的 cookie Cookie cookie = new Coo ...
- Python知乎热门话题数据的爬取实战
import requestsfrom pyquery import PyQuery as pq url = 'https://www.zhihu.com/explore'headers = { 'u ...
- HDU 2588 GCD(欧拉函数)
GCD Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submis ...
- lsattr chattr 文件安全设置
[root@test_android_client_download xianlaigames]# lsattr -------------e- ./jilinmj.apk[root@test_and ...
- 关于使用summernote编辑器提示内容无法汉化临时解决办法
原因:使用汉化summernote-zh-CN.js文件无法汉化 $('#summernote').summernote({ lang: 'zh-CN' }); 解决方法: 打开summernote. ...
- 实战--使用lvs实现四层负载均衡,转发到后端nginx
这个帖子讲得很细致,基本依照这个方案实践. 只是IP是按我自己虚拟机的IP来测试的. http://www.cnblogs.com/arjenlee/p/9262737.html ========== ...
- C#学习-字段
字段的定义由3部分组成,访问修饰符.字段的类型和字段的名称.以下是 public class Person { //姓名,类型为字符串类型 private string name; //年龄,类型为i ...