题目链接:

B. Bakery

题意:

是否存在一条连接特殊和不特殊的边,存在最小值是多少;

思路:

扫一遍所有边;

AC代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>
#include <stack>
#include <map> using namespace std; #define For(i,j,n) for(int i=j;i<=n;i++)
#define mst(ss,b) memset(ss,b,sizeof(ss)); typedef long long LL; template<class T> void read(T&num) {
char CH; bool F=false;
for(CH=getchar();CH<'0'||CH>'9';F= CH=='-',CH=getchar());
for(num=0;CH>='0'&&CH<='9';num=num*10+CH-'0',CH=getchar());
F && (num=-num);
}
int stk[70], tp;
template<class T> inline void print(T p) {
if(!p) { puts("0"); return; }
while(p) stk[++ tp] = p%10, p/=10;
while(tp) putchar(stk[tp--] + '0');
putchar('\n');
} const LL mod=1e9+7;
const double PI=acos(-1.0);
const int inf=1e9+10;
const int N=1e5+10;
const int maxn=1e3+20;
const double eps=1e-12; int n,m,k,x;
int vis[N],u[N],v[N],w[N];
int main()
{
read(n);read(m);read(k);
For(i,1,m)
{
read(u[i]);read(v[i]);read(w[i]);
}
For(i,1,k)
{
read(x);
vis[x]=1;
}
int ans=inf;
For(i,1,m)
{
if(!vis[u[i]]&&vis[v[i]])ans=min(ans,w[i]);
if(!vis[v[i]]&&vis[u[i]])ans=min(ans,w[i]);
}
if(ans==inf)cout<<"-1"<<endl;
else cout<<ans<<endl;
return 0;
}

  

codeforces 707B B. Bakery(水题)的更多相关文章

  1. 【Codeforces 707B】Bakery 水题

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

  2. Codeforces Gym 100531G Grave 水题

    Problem G. Grave 题目连接: http://codeforces.com/gym/100531/attachments Description Gerard develops a Ha ...

  3. codeforces 706A A. Beru-taxi(水题)

    题目链接: A. Beru-taxi 题意: 问那个taxi到他的时间最短,水题; AC代码: #include <iostream> #include <cstdio> #i ...

  4. codeforces 569B B. Inventory(水题)

    题目链接: B. Inventory time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  5. Codeforces 489A SwapSort (水题)

    A. SwapSort time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...

  6. codeforces 688A A. Opponents(水题)

    题目链接: A. Opponents time limit per test 1 second memory limit per test 256 megabytes input standard i ...

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

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

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

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

  9. Codeforces Round #368 (Div. 2) B. Bakery 水题

    B. Bakery 题目连接: http://www.codeforces.com/contest/707/problem/B Description Masha wants to open her ...

随机推荐

  1. eclipse配置python插件

    eclipse配置python主要可以分为以下几个步骤完成: 1. 安装python,python主要有两个版本,python2和python3,这里安装的是python2.7.主要考虑python使 ...

  2. [原]Nginx+Lua服务端合并静态文件

    http://homeway.me 0x01.About 源代码已经上传到github:https://github.com/grasses/nginx-lua-static-merger nginx ...

  3. Mysql主从复制,实现数据同步

    大型网站为了软解大量的并发访问,除了在网站实现分布式负载均衡,远远不够.到了数据业务层.数据访问层,如果还是传统的数据结构,或者只是单单靠一台服务器扛,如此多的数据库连接操作,数据库必然会崩溃,数据丢 ...

  4. 鸟哥的Linux私房菜-----6、文件与文件夹管理

  5. One Person Game(概率+数学)

    There is a very simple and interesting one-person game. You have 3 dice, namelyDie1, Die2 and Die3.  ...

  6. J - Max Sum

    J - Max Sum Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Descrip ...

  7. Storm伪分布式搭建

    配置zookeeper 下载zookeeper tar包 解压:tar -zxvf zookeeper-3.4.10.tar.gz -C /root/training/ 配置 cd /root/tra ...

  8. 记录-JQuery日历插件My97DatePicker日期范围限制

    对于日期控件,有时会有不能选择今天以前的日期这种需求..... My97DatePicker是一个非常优秀的日历插件,不仅支持多种调用模式,还支持日期范围限制. 常规的调用比较简单,如下所示: 1 & ...

  9. ArcGIS Scalebar 比例尺

    说明.这篇博文的示例代码 地图充满body arcgis api for javascript iis怎么离线部署 请参考我前面的博文 1.运行效果 3.HTML代码 <!DOCTYPE htm ...

  10. 红米4A手机刷开发版rom并且获取root权限

    1 bl解锁 Critical partition flashing is not allowed就是因为没有bl解锁. 注册小米账号并且关联手机. 下载bl解锁工具 http://www.miui. ...