結果

問題 No.1805 Approaching Many Typhoon
ユーザー first_vilfirst_vil
提出日時 2022-01-12 20:26:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 1,056 bytes
コンパイル時間 319 ms
コンパイル使用メモリ 87,396 KB
実行使用メモリ 78,068 KB
最終ジャッジ日時 2023-08-09 18:10:20
合計ジャッジ時間 5,592 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
71,616 KB
testcase_01 AC 95 ms
71,576 KB
testcase_02 AC 94 ms
71,284 KB
testcase_03 AC 93 ms
71,584 KB
testcase_04 AC 93 ms
71,488 KB
testcase_05 AC 93 ms
71,504 KB
testcase_06 AC 94 ms
71,568 KB
testcase_07 AC 95 ms
71,480 KB
testcase_08 AC 95 ms
71,568 KB
testcase_09 AC 94 ms
71,476 KB
testcase_10 AC 93 ms
71,608 KB
testcase_11 AC 95 ms
71,568 KB
testcase_12 AC 93 ms
71,480 KB
testcase_13 AC 93 ms
71,656 KB
testcase_14 AC 93 ms
71,608 KB
testcase_15 AC 94 ms
71,608 KB
testcase_16 AC 94 ms
71,592 KB
testcase_17 AC 92 ms
71,648 KB
testcase_18 AC 95 ms
71,436 KB
testcase_19 AC 93 ms
71,536 KB
testcase_20 AC 94 ms
71,836 KB
testcase_21 AC 93 ms
71,640 KB
testcase_22 AC 94 ms
71,428 KB
testcase_23 AC 93 ms
71,428 KB
testcase_24 AC 94 ms
71,668 KB
testcase_25 AC 95 ms
71,484 KB
testcase_26 AC 94 ms
71,568 KB
testcase_27 AC 91 ms
71,668 KB
testcase_28 AC 106 ms
78,040 KB
testcase_29 AC 109 ms
78,036 KB
testcase_30 AC 110 ms
77,836 KB
testcase_31 AC 108 ms
78,068 KB
testcase_32 AC 94 ms
71,440 KB
testcase_33 AC 93 ms
71,604 KB
testcase_34 AC 97 ms
71,436 KB
testcase_35 AC 103 ms
72,628 KB
testcase_36 AC 101 ms
72,280 KB
testcase_37 AC 95 ms
71,476 KB
testcase_38 AC 94 ms
71,488 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()
    if not (1 <= a <= n and 1 <= b <= n):
        while True:
            x = 0
            y = x ^ 2
    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