/* -*- coding: utf-8 -*- * * 2948.cc: No.2948 move move rotti - yukicoder */ #include #include using namespace std; /* constant */ const int MAX_N = 15; const int NBITS = 1 << MAX_N; /* typedef */ /* global variables */ int xs[MAX_N]; bool es[MAX_N][MAX_N]; int dp[NBITS][MAX_N], tbs[MAX_N][MAX_N]; /* subroutines */ /* main */ int main() { int n, m, k; scanf("%d%d%d", &n, &m, &k); for (int i = 0; i < k; i++) scanf("%d", xs + i), xs[i]--; for (int i = 0; i < m; i++) { int u, v; scanf("%d%d", &u, &v); u--, v--; es[u][v] = es[v][u] = true; } int nbits = 1 << n, nmsk = nbits - 1; for (int st = 0; st < n; st++) { for (int bits = 0; bits < nbits; bits++) fill(dp[bits], dp[bits] + n, -1); dp[1 << st][st] = 0; for (int bits = 0; bits < nbits; bits++) for (int i = 0; i < n; i++) if (dp[bits][i] >= 0) { tbs[st][dp[bits][i]] |= (1 << i); for (int j = 0, bj = 1; j < n; j++, bj <<= 1) if (! (bits & bj) && es[i][j] && dp[bits | bj][j] < 0) dp[bits | bj][j] = dp[bits][i] + 1; } } for (int d = 0; d < n; d++) { int bits = nmsk; for (int i = 0; i < k; i++) bits &= tbs[xs[i]][d]; if (bits != 0) { puts("Yes"); return 0; } } puts("No"); return 0; }