#include #include #define chmin(x,y) (x) = min((x),(y)) #define chmax(x,y) (x) = max((x),(y)) using namespace std; using namespace atcoder; using ll = long long; const ll mod = 998244353; using mint = modint998244353; using Graph = vector>>; const vector dx = {1,0,-1,0}, dy = {0,1,0,-1}; pair song(int a, int b, int n){ for(int x = int(n/a); x >= 0; x--){ int y = n - a*x; if(y % b == 0) return(make_pair(x,y/b)); } return(make_pair(-1,-1)); } vector BFS_bit(vector> g, int s){ int n = g.size(); vector res(n,0); queue> q; q.emplace(s,0,(1<> N >> M >> K; vector X(K); for(int i = 0; i < K; i++){ cin >> X[i]; --X[i]; } // prep vector> G(N,vector(N,0)); while(M--){ int u,v; cin >> u >> v; --u; --v; G[u][v] = 1; G[v][u] = 1; } vector> D(K,vector(N)); for(int i = 0; i < K; i++) D[i] = BFS_bit(G,X[i]); // solve bool can = 0; for(int x = 0; x < N; x++){ int vst_time = D[0][x]; for(int i = 1; i < K; i++){ vst_time &= D[i][x]; if(!vst_time) continue; } if(vst_time){ can = 1; break; } } // output cout << (can ? "Yes" : "No") << endl; }