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的更多相关文章

  1. 洛谷——P2935 [USACO09JAN]最好的地方Best Spot

    P2935 [USACO09JAN]最好的地方Best Spot 题目描述 Bessie, always wishing to optimize her life, has realized that ...

  2. $P2935 [USACO09JAN]最好的地方Best Spot$

    P2935 [USACO09JAN]最好的地方Best Spot Floyd的水题(黄题) 海星. 这可能是我第一道发的Floyd的博客 inline void Floyd(){ ;k<=n;k ...

  3. 洛谷 P2935 [USACO09JAN]最好的地方Best Spot

    题目描述 Bessie, always wishing to optimize her life, has realized that she really enjoys visiting F (1 ...

  4. Luogu P2935 最好的地方Best Spot

    Luogu P2935 最好的地方Best Spot 这道题就是一道近乎裸的Floyd,因为数据很小,所以用领接表存图就可以了. #include<bits/stdc++.h> #defi ...

  5. URAL 1934 Black Spot(最短路)

    Black Spot Time limit: 1.0 secondMemory limit: 64 MB Bootstrap: Jones's terrible leviathan will find ...

  6. spot 5、ALOS监督分类波段组成

    spot 5监督分类RGB:412 ALOS分类波段RGB:432

  7. Spot light工具集

    Spot light on UNIX 安装没什么问题 Spot light on Oracle  必须安装32位的客户端,不然搞死你 两者的界面都是吊炸天啊

  8. BZOJ3394: [Usaco2009 Jan]Best Spot 最佳牧场

    3394: [Usaco2009 Jan]Best Spot 最佳牧场 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 11  Solved: 9[Sub ...

  9. 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 ...

随机推荐

  1. swagger2访问url

    swagger : http://localhost:8080/swagger/index.html springboot中的swagger:http://localhost:8080/swagger ...

  2. Jmeter 谷歌插件工具blazemeter录制脚本

    1.下载谷歌浏览器插件工具:blazemeter. 2.在谷歌浏览器中拖放安装扩展工具:blazemeter. 粘贴的图像828x219 13.5 KB 3.测试网站利用这个工具录制jmter脚本. ...

  3. Vue 添加外部的时间插件不触发v-model事件更改数据

    使用的jquery日期插件 最终问题是 在选择完成日期后并未激活 oninput事件,所以也没有激活v-model 去改变date 解决思路: 去插件js文件中,在赋值给dom的时候添加模拟输入事件便 ...

  4. Vue2 异步获取的数据(通过ajax)获取的数据 渲染到dom上

    页面dom结构如下 <ul class="user" id="app"> <li><span>姓名: </span&g ...

  5. 论文阅读笔记三十八:Deformable Convolutional Networks(ECCV2017)

    论文源址:https://arxiv.org/abs/1703.06211 开源项目:https://github.com/msracver/Deformable-ConvNets 摘要 卷积神经网络 ...

  6. ES优化总结

    ES优化总结(特别是在bulk大量数据到ES的时候) https://blog.csdn.net/chenxun_2010/article/details/78602795 将 ELASTICSEAR ...

  7. 将现有项目添加到TFS中

    假设在Projects文件夹中有一个名为WpfApplication1的项目需要添加到TFS. 我们可以这样做: 1.打开视图->团队资源管理器,点击管理连接,在弹出的窗口中选择服务器和团队项目 ...

  8. 一脸懵逼搭建Zookeeper分布式集群

    1:首先将http://zookeeper.apache.org/ 下载好的zookeeper-3.4.5.tar.gz上传到三台虚拟机上,之前博客搭建好的(安装Zookeeper之前记得安装好你的j ...

  9. 一脸懵逼学习Hadoop中的序列化机制——流量求和统计MapReduce的程序开发案例——流量求和统计排序

    一:序列化概念 序列化(Serialization)是指把结构化对象转化为字节流.反序列化(Deserialization)是序列化的逆过程.即把字节流转回结构化对象.Java序列化(java.io. ...

  10. bzoj2908

    题解: 我的做法好像跟网上不太一样.. 首先分位讨论 我的做法是先观察出了一个性质 这个答案只跟最后一个0出现的位置有关(这个随便yy一下很容易出来因为运算有0则1) 然后问题就变成了 给出一棵树,支 ...