結果

問題 No.1805 Approaching Many Typhoon
ユーザー first_vilfirst_vil
提出日時 2022-01-12 20:22:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 931 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 11,064 KB
実行使用メモリ 9,056 KB
最終ジャッジ日時 2023-08-09 18:09:14
合計ジャッジ時間 2,265 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
8,696 KB
testcase_01 AC 20 ms
8,596 KB
testcase_02 AC 19 ms
8,600 KB
testcase_03 AC 18 ms
8,560 KB
testcase_04 AC 19 ms
8,640 KB
testcase_05 AC 18 ms
8,756 KB
testcase_06 AC 17 ms
8,680 KB
testcase_07 AC 18 ms
8,680 KB
testcase_08 AC 18 ms
8,644 KB
testcase_09 AC 19 ms
8,744 KB
testcase_10 AC 18 ms
8,644 KB
testcase_11 AC 19 ms
8,728 KB
testcase_12 AC 18 ms
8,744 KB
testcase_13 AC 18 ms
8,556 KB
testcase_14 AC 18 ms
8,644 KB
testcase_15 AC 19 ms
8,748 KB
testcase_16 AC 18 ms
8,760 KB
testcase_17 AC 19 ms
8,560 KB
testcase_18 AC 18 ms
8,596 KB
testcase_19 AC 18 ms
8,668 KB
testcase_20 AC 18 ms
8,684 KB
testcase_21 AC 18 ms
8,644 KB
testcase_22 AC 18 ms
8,632 KB
testcase_23 AC 18 ms
8,568 KB
testcase_24 AC 18 ms
8,576 KB
testcase_25 AC 18 ms
8,676 KB
testcase_26 AC 17 ms
8,640 KB
testcase_27 AC 18 ms
8,696 KB
testcase_28 AC 21 ms
9,056 KB
testcase_29 AC 21 ms
8,868 KB
testcase_30 AC 21 ms
8,964 KB
testcase_31 AC 22 ms
9,004 KB
testcase_32 AC 18 ms
8,632 KB
testcase_33 AC 17 ms
8,700 KB
testcase_34 AC 19 ms
8,640 KB
testcase_35 AC 19 ms
8,772 KB
testcase_36 AC 20 ms
8,828 KB
testcase_37 AC 18 ms
8,628 KB
testcase_38 AC 17 ms
8,640 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 = mi1()
    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