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. sass基础—属性嵌套以及跳出嵌套 @at-root

    /*注意:定义的变量若是没有使用则不会编译到css文件中.*//*1)sass的局部变量*/$font:14px;//定义$font:12px !default; //没有default时是重新赋值, ...

  2. druid配置oracle遇到: 未找到要求的 FROM 关键字 errorCode 923, state 42000

    2018年05月29日 16:41:17 阅读数:518 问题背景 项目要连接oracle数据,采用的是durid连接池,但是基本配置下来,运行时发现了这个错误. 方案 可能有的一个错误就是,拼凑sq ...

  3. 图像特征的提取(gaussian,gabor,frangi,hessian,Morphology...)及将图片保存为txt文件

    # -*- coding: utf-8 -*- #2018-2-19 14:30:30#Author:Fourmi_gsj import cv2 import numpy as np import p ...

  4. 如果IDEA右上角的tomcat消失了,解决办法

    看了很多博客都没有找到解决办法,还是老师帮我解决的

  5. JCenter下载太慢, jcenter修改 https为http也许能帮助你

    今天导入一个工程到studio,一直卡在下载那块. 看到下载地址是:https://jcenter.bintray.com/........https!!!! 到浏览器下载,果然也下载不下来.. 于是 ...

  6. 微信小程序API 登录-wx.login(OBJECT) + 获取微信用户唯一标识openid | 小程序

    wx.login(OBJECT) 调用接口获取登录凭证(code)进而换取用户登录态信息,包括用户的唯一标识(openid) 及本次登录的 会话密钥(session_key).用户数据的加解密通讯需要 ...

  7. GO语言标准库—命令行参数解析FLAG

    flag包是Go语言标准库提供用来解析命令行参数的包,使得开发命令行工具更为简单 常用方法 1.flag.Usage 输出使用方法,如linux下ls -h的帮助输出 2.flag.Type(参数名, ...

  8. 通过安装memadmin对memcache进行可视化管理

    https://blog.csdn.net/reblue520/article/details/70792891

  9. 【AtCoder】ExaWizards 2019

    ExaWizards 2019 C - Snuke the Wizard 发现符文的相对位置不变,直接二分某个位置是否到达最左或最右来计算 #include <bits/stdc++.h> ...

  10. 在启用了“编辑并继续”时,修改包含 lambda 表达式的“method”将会阻止调试会话继续进行

    将所有的引用的“复制到本地”属性都设置成false就可以了