func_code_string: #include <bits/stdc++.h>   using namespace std;   struct node {     long long lvl1, lvl2, id;   };   node t[500005];   bool cmp(struct node x, struct node y) {     if (x.lvl1 < y.lvl1)       return true;     else       return false;   }   vector<node> sh;   vector<long long> adj[500005];   long long vis[500005], lvl1[500005], lvl2[500005];   void bfs1(long long n = 1) {     queue<long long> q;     q.push(n);     vis[n] = 1;     lvl1[n] = 0;     while (!q.empty()) {       long long x = q.front();       q.pop();       for (auto &cv : adj[x]) {         if (vis[cv]) continue;         q.push(cv);         vis[cv] = 1;         lvl1[cv] = lvl1[x] + 1;       }     }   }   void bfs2(long long n) {     queue<long long> q;     q.push(n);     vis[n] = 1;     lvl2[n] = 0;     while (!q.empty()) {       long long x = q.front();       q.pop();       for (auto &cv : adj[x]) {         if (vis[cv]) continue;         q.push(cv);         vis[cv] = 1;         lvl2[cv] = lvl2[x] + 1;       }     }   }   node combine(node x, node y) {     if (x.lvl2 > y.lvl2)       return x;     else       return y;   }   void build(long long n) {     for (long long i = n - 1; i > 0; --i)       t[i] = combine(t[i << 1], t[i << 1 | 1]);   }   node query(long long l, long long r, long long n) {     node res;     res.lvl2 = res.lvl1 = res.id = 0;     for (l += n, r += n; l < r; l >>= 1, r >>= 1) {       if (l & 1) res = (combine(t[l++], res));       if (r & 1) res = combine(t[--r], res);     }     return res;   }   long long arr[500005];   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(0);     long long i, j, k, l, m, n, x, y;     cin >> n >> m >> k;     for (i = 0; i < k; i++) {       cin >> arr[i];     }     for (i = 0; i < m; i++) {       cin >> x;       cin >> y;       adj[x].push_back(y);       adj[y].push_back(x);     }     bfs1();     memset(vis, 0, sizeof vis);     bfs2(n);     for (i = 0; i < k; i++) {       node temp;       temp.id = arr[i];       temp.lvl1 = lvl1[arr[i]];       temp.lvl2 = lvl2[arr[i]];       sh.push_back(temp);     }     sort(sh.begin(), sh.end(), cmp);     for (i = 0; i < sh.size(); i++) {       t[i + k].lvl1 = sh[i].lvl1;       t[i + k].lvl2 = sh[i].lvl2;       t[i + k].id = sh[i].id;     }     build(k);     long long ans = 0;     for (i = 0; i + 1 < sh.size(); i++) {       long long temp;       temp = sh[i].lvl1;       temp++;       temp += query(i + 1, sh.size(), sh.size()).lvl2;       ans = max(ans, temp);     }     cout << min(lvl2[1], ans) << endl;     return 0;   }   