結果

問題 No.1805 Approaching Many Typhoon
ユーザー 8989
提出日時 2022-02-21 12:49:20
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,189 bytes
コンパイル時間 464 ms
コンパイル使用メモリ 87,240 KB
実行使用メモリ 77,372 KB
最終ジャッジ日時 2023-09-12 04:13:27
合計ジャッジ時間 5,674 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,620 KB
testcase_01 AC 72 ms
71,180 KB
testcase_02 AC 75 ms
71,392 KB
testcase_03 AC 73 ms
71,568 KB
testcase_04 AC 73 ms
71,168 KB
testcase_05 AC 73 ms
71,288 KB
testcase_06 WA -
testcase_07 AC 74 ms
71,380 KB
testcase_08 AC 74 ms
71,636 KB
testcase_09 AC 73 ms
71,584 KB
testcase_10 AC 72 ms
71,432 KB
testcase_11 AC 72 ms
71,228 KB
testcase_12 AC 74 ms
71,396 KB
testcase_13 AC 72 ms
71,616 KB
testcase_14 WA -
testcase_15 AC 73 ms
71,280 KB
testcase_16 AC 73 ms
71,376 KB
testcase_17 AC 74 ms
71,416 KB
testcase_18 AC 75 ms
71,492 KB
testcase_19 AC 74 ms
71,540 KB
testcase_20 AC 75 ms
71,340 KB
testcase_21 AC 72 ms
71,364 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 73 ms
71,320 KB
testcase_25 AC 71 ms
71,444 KB
testcase_26 AC 74 ms
71,656 KB
testcase_27 AC 73 ms
71,400 KB
testcase_28 AC 97 ms
77,372 KB
testcase_29 AC 101 ms
76,772 KB
testcase_30 AC 102 ms
76,992 KB
testcase_31 AC 97 ms
76,896 KB
testcase_32 AC 73 ms
71,424 KB
testcase_33 AC 76 ms
71,388 KB
testcase_34 AC 76 ms
71,316 KB
testcase_35 AC 81 ms
71,312 KB
testcase_36 AC 87 ms
75,576 KB
testcase_37 AC 73 ms
71,276 KB
testcase_38 AC 73 ms
71,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

v,e = map(int, input().split())
s,g = map(int,input().split())
# adj[s]: ノード s に隣接する(ノード, 重み)をリストで持つ
adj = [[] for _ in range(v)]
for i in range(e):
    s, t= map(int, input().split())
    s -= 1
    t -= 1
    adj[s].append((t, 1))
    adj[t].append((s, 1))
    #双方向でないときは下消す
u = int(input())
pp = list(map(int,input().split()))
from heapq import heappush, heappop
INF = 10 ** 9
def dijkstra(s, n): # (始点, ノード数)
    global pp
    before = [-1]*n
    dist = [INF] * n
    hq = [(0, s)] # (distance, node)
    dist[s] = 0
    seen = [False] * n # ノードが確定済みかどうか
    for i in range(len(pp)):
        seen[pp[i] - 1] = True
    while hq:
        v = heappop(hq)[1] # ノードを pop する
        seen[v] = True
        for to, cost in adj[v]: # ノード v に隣接しているノードに対して
            if seen[to] == False and dist[v] + cost < dist[to]:
                before[to] = v
                dist[to] = dist[v] + cost
                heappush(hq, (dist[to], to))
    return dist
QQ = dijkstra(s-2, v)
#print(QQ)
if QQ[g - 1] == INF:
    print("No")
else:
    print("Yes")
0