結果

問題 No.1805 Approaching Many Typhoon
ユーザー first_vilfirst_vil
提出日時 2022-01-12 20:25:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 954 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 82,584 KB
実行使用メモリ 66,028 KB
最終ジャッジ日時 2024-04-27 12:55:26
合計ジャッジ時間 3,044 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
54,140 KB
testcase_01 AC 44 ms
54,320 KB
testcase_02 AC 44 ms
54,796 KB
testcase_03 AC 44 ms
54,208 KB
testcase_04 AC 43 ms
54,684 KB
testcase_05 AC 45 ms
54,104 KB
testcase_06 AC 45 ms
54,648 KB
testcase_07 AC 44 ms
55,064 KB
testcase_08 AC 43 ms
55,464 KB
testcase_09 AC 43 ms
54,512 KB
testcase_10 AC 43 ms
54,320 KB
testcase_11 AC 43 ms
56,300 KB
testcase_12 AC 45 ms
54,452 KB
testcase_13 AC 45 ms
54,324 KB
testcase_14 AC 45 ms
56,088 KB
testcase_15 AC 45 ms
55,220 KB
testcase_16 AC 45 ms
55,196 KB
testcase_17 AC 46 ms
54,436 KB
testcase_18 AC 46 ms
55,200 KB
testcase_19 AC 45 ms
55,484 KB
testcase_20 AC 44 ms
55,900 KB
testcase_21 AC 45 ms
55,192 KB
testcase_22 AC 45 ms
54,808 KB
testcase_23 AC 43 ms
55,672 KB
testcase_24 AC 44 ms
55,480 KB
testcase_25 AC 44 ms
55,740 KB
testcase_26 AC 43 ms
55,040 KB
testcase_27 AC 44 ms
54,140 KB
testcase_28 AC 60 ms
65,816 KB
testcase_29 AC 57 ms
65,728 KB
testcase_30 AC 56 ms
66,028 KB
testcase_31 AC 56 ms
65,180 KB
testcase_32 AC 44 ms
54,620 KB
testcase_33 AC 43 ms
55,316 KB
testcase_34 AC 46 ms
55,772 KB
testcase_35 AC 46 ms
55,892 KB
testcase_36 AC 48 ms
56,776 KB
testcase_37 AC 43 ms
54,436 KB
testcase_38 AC 44 ms
54,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

int1 = lambda x: int(x) - 1

# input = lambda: sys.stdin.buffer.readline()
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
i1 = lambda: int1(input())
mi = lambda: map(int, input().split())
mi1 = lambda: map(int1, input().split())
li = lambda: list(mi())
li1 = lambda: list(mi1())
lli = lambda n: [li() for _ in range(n)]

INF = float("inf")
mod = int(1e9 + 7)
# mod = 998244353

n, m = mi()
s, t = mi1()
g = [list() for i in range(n)]
for i in range(m):
    a, b = mi()
    a, b = a - 1, b - 1
    g[a].append(b)
    g[b].append(a)
ng = [False] * n
input()
for i in li1():
    ng[i] = True

from collections import deque

que = deque()
que.append(s)
dp = [INF] * n
dp[s] = 0
while que:
    cur = que.popleft()
    for to in g[cur]:
        if ng[to]:
            continue
        if dp[to] > dp[cur] + 1:
            dp[to] = dp[cur] + 1
            que.append(to)
print("Yes" if not ng[s] and dp[t] != INF else "No")
0