[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 ...
随机推荐
- Jenkins构建后发送邮件
我们首先安装Jenkins邮件扩展插件“ Email Extension Plugin ”. Jenkins和插件的安装方法见上一篇文章:http://qicheng0211.blog.51cto.c ...
- Windows文件系统
微软在Dos/Windows系列操作系统中共使用了6种不同的文件系统(包括即将在windows的下一个版本中使用的Winfs).它们分别是:FAt12.FAT16.FAT32.NTFS.NTFS5.0 ...
- Java利用POI读取Excel
官网直接下载POI http://poi.apache.org/ package com.CommonUtil; import java.io.File; import java.io.FileIn ...
- A.Ocean的礼物线段树
A: Ocean的礼物 Time Limit: 2 s Memory Limit: 128 MB Submit My Status Problem Description 皇家理工存在一段很神 ...
- MVC AOP解决JsonResult返回json时间格式
新建JsonNetResult类:JsonResult public class JsonNetResult: JsonResult { public JsonNetResult() { Settin ...
- python-中缀转换后缀并计算
这个好像比较简单. 前缀规则好像还没有理清楚. # coding = utf-8 class Stack: def __init__(self): self.items = [] # 是否为空 def ...
- tomcat启动成功但是访问方面都是404
1.开发环境与错误情况 开发环境是jdk1.7+maven+git+spring MVC+spring+mybatis+mysql. 楼主做小例子的时候发现,tomcat成功启动,但是访问主页,页面提 ...
- [转] 前后端分手大师——MVVM 模式
之前对 MVVM 模式一直只是模模糊糊的认识,正所谓没有实践就没有发言权,通过这两年对 Vue 框架的深入学习和项目实践,终于可以装B了有了拨开云雾见月明的感觉. Model–View–ViewMod ...
- 基于Postman的API自动化测试
https://segmentfault.com/a/1190000005055899 1. 安装 两种安装方式,我热衷于以chrome插件形式安装 Chrome插件 Mac App 2. 发送请求 ...
- 【Android】Android 代码判断是否获取ROOT权限(一)
[Android]Android 代码判断是否获取ROOT权限 方法比较简单,直接粘贴代码 public synchronized boolean getRootAhth() { Process pr ...