CF1307D Cow and Fields

题目描述

给定一个有 $n$ 个节点 $m$ 条边的无向图,一个顶点集 $S$。 你需要选择两个顶点 $u,v(u\ne v,u\in S,v\in S)$ 并连接这两个顶点(允许 $u,v$ 之间已经有连边),求连接后从顶点 $1$ 到顶点 $n$ 最短路的最大值。 **注意,该操作仅能进行一次。** 保证给定的图联通。

输入格式

第一行三个整数 $n,m,k$($2 \le n \le 2 \cdot 10^5$,$n-1 \le m \le 2 \cdot 10^5$,$2 \le k \le n$),分别表示点数,边数和点集的大小。 第二行 $k$ 个整数 $a_1, a_2, \ldots, a_k$($1 \le a_i \le n$),表示点集。 下面 $m$ 行,每行两个整数,表示这两个整数之间有一条边。

输出格式

一行一个整数,表示添加一条边之后从顶点 $1$ 到顶点 $n$ 最短路的最大值。

说明/提示

The graph for the first example is shown below. The special fields are denoted by red. It is optimal for Farmer John to add a road between fields $ 3 $ and $ 5 $ , and the resulting shortest path from $ 1 $ to $ 5 $ is length $ 3 $ . ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1307D/a6a22f5ed84788383fc241ea2dde08c9f28bd36f.png)The graph for the second example is shown below. Farmer John must add a road between fields $ 2 $ and $ 4 $ , and the resulting shortest path from $ 1 $ to $ 5 $ is length $ 3 $ . ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1307D/6e910397f1b2c44c166ab9348389635244758f12.png)