codeforces 707B 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(水题)的更多相关文章
- 【Codeforces 707B】Bakery 水题
对每个storages找一下最短的相邻边 #include <cstdio> #define N 100005 #define inf 0x3f3f3f3f using namespace ...
- Codeforces Gym 100531G Grave 水题
Problem G. Grave 题目连接: http://codeforces.com/gym/100531/attachments Description Gerard develops a Ha ...
- codeforces 706A A. Beru-taxi(水题)
题目链接: A. Beru-taxi 题意: 问那个taxi到他的时间最短,水题; AC代码: #include <iostream> #include <cstdio> #i ...
- codeforces 569B B. Inventory(水题)
题目链接: B. Inventory time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces 489A SwapSort (水题)
A. SwapSort time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...
- codeforces 688A A. Opponents(水题)
题目链接: A. Opponents time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- 【CodeForces - 707B】Bakery(思维水题)
Bakery Descriptions 玛莎想在从1到n的n个城市中开一家自己的面包店,在其中一个城市烘焙松饼. 为了在她的面包房烘焙松饼,玛莎需要从一些储存的地方建立面粉供应.只有k个仓库,位于不同 ...
- CodeForces 707B Bakery (水题,暴力,贪心)
题意:给定n个城市,其中有k个有仓库,问你在其他n-k个城市离仓库的最短距离是多少. 析:很容易想到暴力,并且要想最短,那么肯定是某一个仓库和某一个城市直接相连,这才是最优,所以只要枚举仓库,找第一个 ...
- Codeforces Round #368 (Div. 2) B. Bakery 水题
B. Bakery 题目连接: http://www.codeforces.com/contest/707/problem/B Description Masha wants to open her ...
随机推荐
- python学习 05 函数switch功能
1.python没有switch功能,利用字典实现 如果用if else,可行但是效率不高
- Mysql的学习研究
2017年5月16日11:26:17 从今天开始过一遍数据库的基础教程,加油!!!!! 看了之后对一些基础知识有了理解,加油... 笔记: 2017年5月16日11:35:46mysql的基础教程1. ...
- Ubuntu 12.04使用uginx+fastcgi-mono-server2部署asp.net 网站
Ubuntu 12.04使用uginx+fastcgi-mono-server2部署asp.net 网站 1.安装nginx和mono-fastcgi-server2 sodu apt-get in ...
- 记录-springMVC访问web-inf下文件问题+在jsp页面导入jquery插件路径不对问题
环境:spring + springMvc + mybatis + maven 关于在springMVC环境访问web-inf目录下文件,其一有在springMVC xml文件下加 <!-- 对 ...
- 函数的光滑化或正则化 卷积 应用 两个统计独立变量X与Y的和的概率密度函数是X与Y的概率密度函数的卷积
http://graphics.stanford.edu/courses/cs178/applets/convolution.html Convolution is an operation on t ...
- php自定义函数: 加密下载地址
function getdownurl($downurl, $extime = "3600", $serverid = 1) { if (empty($downurl)) { re ...
- spring+hibernate+springmvc整合框架搭建
搭建maven web项目这里不再讲述,详情请查看http://www.cnblogs.com/wql025/p/5215570.html 现在讲述项目的搭建过程. 1.通过maven导入项目所用的j ...
- 如何解决Asp.Net MVC和WebAPI的Controller名称不能相同的问题
1.问题描述 假如有一个文章的业务(Article),我们在 Controllers文件夹中创建MVC Controller和Api Controller,各个Controller中都有相同的获取文章 ...
- 扣出thinkphp数据库操作类
假如你是一位thinkphp的使用者,想必你会觉得thinkphp操作数据库非常方便.现在在你面前有一个非常小的作业,小到完全没有必要用thinkphp去完成它.但是你又觉得不用thinkphp的话, ...
- chorme 插件
json-handle: json可视化工具 开发中需要用到json,在浏览器显示的json非常乱,难以理解.有没有让人一目了然的工具,让json看起来非常直观呢,json-handle随之而出,包含 ...