結果

問題 No.1805 Approaching Many Typhoon
ユーザー flippergo
提出日時 2024-11-19 15:24:17
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 48 ms / 2,000 ms
+ 622µs
コード長 577 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 64 ms
コンパイル使用メモリ 83,108 KB
実行使用メモリ 76,656 KB
最終ジャッジ日時 2026-09-26 16:59:18
合計ジャッジ時間 3,742 ms
ジャッジサーバーID
(参考情報)
judge4_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import deque
N,M = map(int,input().split())
s,g = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
U = int(input())
I = set(list(map(int,input().split())))
G = {i:[] for i in range(1,N+1)}
for i in range(M):
    a,b = A[i]
    if a in I or b in I:continue
    G[a].append(b)
    G[b].append(a)
dist = [-1]*(N+1)
dist[s] = 0
que = deque([s])
while que:
    x = que.popleft()
    for y in G[x]:
        if dist[y]==-1:
            dist[y] = dist[x]+1
            que.append(y)
if dist[g]==-1:
    print("No")
else:
    print("Yes")
0