Bakery

Masha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose connects some pair of cities.

To bake muffins in her bakery, Masha needs to establish flour supply from some storage. There are only k storages, located in different cities numbered a1, a2, …, ak.

Unforunately the law of the country Masha lives in prohibits opening bakery in any of the cities which has storage located in it. She can open it only in one of another n - k cities, and, of course, flour delivery should be paid — for every kilometer of path between storage and bakery Masha should pay 1 ruble.

Formally, Masha will pay x roubles, if she will open the bakery in some city b (ai ≠ b for every 1 ≤ i ≤ k) and choose a storage in some city s (s = aj for some 1 ≤ j ≤ k) and b and s are connected by some path of roads of summary length x (if there are more than one path, Masha is able to choose which of them should be used).

Masha is very thrifty and rational. She is interested in a city, where she can open her bakery (and choose one of k storages and one of the paths between city with bakery and city with storage) and pay minimum possible amount of rubles for flour delivery. Please help Masha find this amount.

Input
The first line of the input contains three integers n, m and k (1 ≤ n, m ≤ 105, 0 ≤ k ≤ n) — the number of cities in country Masha lives in, the number of roads between them and the number of flour storages respectively.

Then m lines follow. Each of them contains three integers u, v and l (1 ≤ u, v ≤ n, 1 ≤ l ≤ 109, u ≠ v) meaning that there is a road between cities u and v of length of l kilometers .

If k > 0, then the last line of the input contains k distinct integers a1, a2, …, ak (1 ≤ ai ≤ n) — the number of cities having flour storage located in. If k = 0 then this line is not presented in the input.

Output
Print the minimum possible amount of rubles Masha should pay for flour delivery in the only line.

If the bakery can not be opened (while satisfying conditions) in any of the n cities, print  - 1 in the only line.

Examples
input
5 4 2
1 2 5
1 2 3
2 3 4
1 4 10
1 5
output
3

input
3 1 1
1 2 3
3
output
-1

题意
在n个城市中,在k个城市中建造仓库的,在剩下的城市中建一个面包店, 仓库和面包店之间必须有一条路相连,求出满足条件的面包店和仓库的最小距离。


思路
把每个边存起来,如果某个边的起点和终点一个是仓库,一个不是,那这条边就可能的情况,在所有情况中找出距离最小的。
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <stack>
#include <cstdio>
#include <vector>
#include <utility>
#include <cstring>
#include <iostream>
#include <algorithm>
#define eps 1e-8
#define PI acos(-1)
#define INF 0x3f3f3f3f
#define N 100005
#define newmax(a,b) a>b?a:b
#define newmin(a,b) a>b?b:a
#define Lowbit(x) (x&-x)
using namespace std;
typedef long long int LL;
const int dir[4][2]= { {1,0},{0,1},{-1,0},{0,-1} };
struct EDGE
{
    int u,v,l;
}edge[N];
int main()
{
    int ha[N]={0};
    int a,n,m,k,ans=INF;
    scanf("%d%d%d",&n,&m,&k);
    for(int i=0;i<m;i++)
        scanf("%d%d%d",&edge[i].u,&edge[i].v,&edge[i].l);
    for(int i=0;i<k;i++)
    {
        scanf("%d",&a);
        ha[a]=1;
    }
    for(int i=0;i<m;i++)
        if(ha[edge[i].u]+ha[edge[i].v]==1)
            ans=min(edge[i].l,ans);
    if(ans==INF)
        printf("-1\n");
    else
        printf("%d\n",ans);
    return 0;
}
### Unity Bakery 插件概述 Unity 中的 Bakery 插件是一个强大的光照贴图烘焙工具,旨在提供高质量的实时全局光照效果。该插件不仅支持多种高级功能,还能够显著提升项目的视觉质量。 #### 功能特性 Bakery 提供了一系列先进的烘焙选项: - **高端 GPU 加速**:通过利用现代显卡的强大计算能力,特别是 NVIDIA 的 RTX 系列硬件,可以极大加快烘焙过程的速度[^2]。 - **修复常见伪影**:有效处理诸如接缝、光线/阴影泄漏以及不正确的阴影终止等问题,确保最终图像的质量不受影响。 - **多源光照支持**:允许同时烘焙来自多个不同类型光源(点灯、聚光灯等)的直接和间接光照贡献,并能存储额外的数据如方向向量或球谐系数等。 - **兼容性验证**:为了保证准确性,Bakery 的输出已经过严格测试并与知名无偏差渲染引擎 Mitsuba 对比一致。 #### 使用指南 当准备使用 Bakery 来优化项目内的光照表现时,请遵循以下指导原则: 对于预制体 (Prefab),需要注意其特殊的烘焙行为。与常规场景对象不同的是,在进行光照贴图预览或者实际构建过程中,预制体的相关操作进度条并不会出现在编辑器界面底部;相反,它会在 Windows 操作系统的任务栏里以 Unity 图标的形式展示出来[^3]。 要启动一次完整的光照贴图更新流程,可以通过导航至 `Window` -> `Rendering` -> `Lighting Settings...` 找到设置面板并点击 `Generate Lighting` 按钮触发整个工程范围内所有必要的重新计算工作。这一步骤同样适用于包含有自定义材质属性的对象实例化版本。 ```csharp // C# 脚本示例 - 自动化光照贴图生成 using UnityEngine; using UnityEditor; public class AutoBake : MonoBehaviour { [MenuItem("Tools/Auto Bake")] static void DoAutoBake() { Lightmapping.BakeAsync(); } } ``` 此脚本片段展示了如何创建一个简单的菜单项来调用异步光照贴图生成功能,从而简化日常开发中的重复劳动。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值