枚举。

枚举每一条边,如果发现边的一端$f[u]=1$,另一端$f[v]=0$,那么更新答案,取最小值就好了。

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<iostream>
using namespace std;
typedef long long LL;
const double pi=acos(-1.0),eps=1e-;
void File()
{
freopen("D:\\in.txt","r",stdin);
freopen("D:\\out.txt","w",stdout);
}
template <class T>
inline void read(T &x)
{
char c = getchar(); x = ;while(!isdigit(c)) c = getchar();
while(isdigit(c)) { x = x * + c - ''; c = getchar(); }
} const int INF=0x7FFFFFFF;
const int maxn=;
int n,m,k;
bool f[maxn];
struct X{int u,v,w;}s[maxn]; int main()
{
scanf("%d%d%d",&n,&m,&k);
for(int i=;i<=m;i++) scanf("%d%d%d",&s[i].u,&s[i].v,&s[i].w);
for(int i=;i<=k;i++)
{
int x; scanf("%d",&x);
f[x]=;
}
int ans=INF;
for(int i=;i<=m;i++)
{
if(f[s[i].u]&&f[s[i].v]) continue;
if(!f[s[i].u]&&!f[s[i].v]) continue;
ans=min(ans,s[i].w);
}
if(ans==INF) printf("-1\n");
else printf("%d\n",ans);
return ;
}

CodeForces 707B Bakery的更多相关文章

  1. 【最小生成树】Codeforces 707B Bakery

    题目链接: http://codeforces.com/problemset/problem/707/B 题目大意: 给你N个点M条无向边,其中有K个面粉站,现在一个人要在不是面粉站的点上开店,问到面 ...

  2. CodeForces 707B Bakery (水题,暴力,贪心)

    题意:给定n个城市,其中有k个有仓库,问你在其他n-k个城市离仓库的最短距离是多少. 析:很容易想到暴力,并且要想最短,那么肯定是某一个仓库和某一个城市直接相连,这才是最优,所以只要枚举仓库,找第一个 ...

  3. Bakery CodeForces - 707B (最短路的思路题)

    Masha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. The ...

  4. codeforces 707B B. Bakery(水题)

    题目链接: B. Bakery 题意: 是否存在一条连接特殊和不特殊的边,存在最小值是多少; 思路: 扫一遍所有边: AC代码: #include <iostream> #include ...

  5. 【CodeForces - 707B】Bakery(思维水题)

    Bakery Descriptions 玛莎想在从1到n的n个城市中开一家自己的面包店,在其中一个城市烘焙松饼. 为了在她的面包房烘焙松饼,玛莎需要从一些储存的地方建立面粉供应.只有k个仓库,位于不同 ...

  6. 【Codeforces 707B】Bakery 水题

    对每个storages找一下最短的相邻边 #include <cstdio> #define N 100005 #define inf 0x3f3f3f3f using namespace ...

  7. Codeforeces 707B Bakery(BFS)

    B. Bakery time limit per test 2 seconds memory limit per test 256 megabytes input standard input out ...

  8. CodeForces–833B--The Bakery(线段树&&DP)

    B. The Bakery time limit per test 2.5 seconds memory limit per test 256 megabytes input standard inp ...

  9. CCPC-Wannafly Summer Camp 2019 Day1

    A - Jzzhu and Cities CodeForces - 449B 题意:n座城市,m条路,k条铁路啥的吧,然后要求最多能删多少条铁路保持1到$n$的最短路不变. 思路:因为铁路是从1出发的 ...

随机推荐

  1. 迟到的 WPF 学习 —— 控件

    这一章书中内容比较多而杂,但每个对象的内容又相对简短,所以只挑选里边有代表性的内容做记录. 1. Label 控件:一个基础的简单的 ContentControl,Labe 支持快捷键文本的设置,可以 ...

  2. 从异步更新进度想起的事儿——IProgress

    今天,在群里向大家请教了这样一个问题:“两个对象(类.窗体或什么)之间,要完成比较频繁的报告进度更新都有哪些好的方式”,Somebody 跳出来给出了个“IProgress”,没了解过,后面围绕着它讨 ...

  3. 用来代替本机IP的万能IP:127.0.0.1

    用来代替本机IP的通用IP:127.0.0.1

  4. 关于 HttpModule配置问题

    在经典模式下,配置到System.web节点 在IIS7以上的集成模式下,要配置到<system.webServer>节点 否则会出现类似一下的错误: 具体配置如下: <config ...

  5. Make Things Move -- Javascript html5版(三)三角函数形式的动画

    角度制和弧度制 生活中通常是用角度度来理解的,代码里都是用弧度制来计算. 角度转弧度:DEG_TO_RAD = Math.PI / 180 弧度装角度:RAD_TO_DEG = 180 / Math. ...

  6. ASP.NET MVC页面UI之多级数据选择UI(行业信息、专业信息、职位信息的选择)

    多级数据选择操作在开发中是常见的操作,比如选择行业信息时,一般有个大类,每个大类下边又包含很多小类,本文简单实现了弹出窗口一级一级选择功能. 本文博客出处:http://www.kwstu.com/A ...

  7. OpenCascade

    Hello World of OpenCascade   Hello World of OpenCascade eryar@163.com 摘要Abstract:以一个经典的Hello World程序 ...

  8. Machine Learning/Introducing Logistic Function

    Machine Learning/Introducing Logistic Function 打算写点关于Machine Learning的东西, 正好也在cnBlogs上新开了这个博客, 也就更新在 ...

  9. Docker ( Is docker really better than VM ?)

    Docker is so popular. Arha? Let's try! Docker needs the linux kernel shoud be upper than 3.10.x Let' ...

  10. 为outlook增加“邮件召回”功能

    outlook 2007开始软件自带邮件召回功能.2003版本没有,可惜此版本盗版最厉害,用户很广,这次项目中用户分布很广,其中outlook2003版本用户数甚多,达到397人. 不可能让他们新装2 ...