/* -*- coding: utf-8 -*- * * 1805.cc: No.1805 Approaching Many Typhoon - yukicoder */ #include #include #include #include using namespace std; /* constant */ const int MAX_N = 2000; /* typedef */ typedef vector vi; typedef queue qi; /* global variables */ vi nbrs[MAX_N]; bool ds[MAX_N], fs[MAX_N]; /* subroutines */ /* main */ int main() { int n, m, st, gl; scanf("%d%d%d%d", &n, &m, &st, &gl); st--, gl--; for (int i = 0; i < m; i++) { int u, v; scanf("%d%d", &u, &v); u--, v--; nbrs[u].push_back(v); nbrs[v].push_back(u); } int un; scanf("%d", &un); for (int i = 0; i < un; i++) { int ii; scanf("%d", &ii), ii--; fs[ii] = true; } ds[st] = true; qi q; q.push(st); while (! q.empty()) { int u = q.front(); q.pop(); for (auto v: nbrs[u]) if (! ds[v] && ! fs[v]) { ds[v] = true; q.push(v); } } if (ds[gl]) puts("Yes"); else puts("No"); return 0; }