結果

問題 No.1190 Points
ユーザー Chihaya_chanChihaya_chan
提出日時 2020-09-03 00:08:40
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,322 bytes
コンパイル時間 313 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 111,660 KB
最終ジャッジ日時 2024-05-01 20:22:01
合計ジャッジ時間 13,241 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
67,968 KB
testcase_01 WA -
testcase_02 AC 50 ms
68,096 KB
testcase_03 AC 440 ms
100,428 KB
testcase_04 AC 390 ms
98,560 KB
testcase_05 AC 366 ms
97,740 KB
testcase_06 AC 484 ms
103,208 KB
testcase_07 AC 579 ms
103,964 KB
testcase_08 AC 560 ms
104,160 KB
testcase_09 AC 601 ms
108,232 KB
testcase_10 AC 572 ms
104,700 KB
testcase_11 AC 482 ms
103,808 KB
testcase_12 AC 590 ms
106,476 KB
testcase_13 AC 487 ms
101,888 KB
testcase_14 WA -
testcase_15 AC 720 ms
109,952 KB
testcase_16 WA -
testcase_17 AC 640 ms
107,552 KB
testcase_18 AC 330 ms
98,560 KB
testcase_19 WA -
testcase_20 AC 423 ms
100,872 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 763 ms
111,660 KB
testcase_24 AC 704 ms
110,504 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# Points
# 拡張ダイクストラ
import heapq
N, M, P = map(int, input().split())
start, goal = map(int, input().split())
G = [[] for i in range(2*10**5+1)]
for i in range(M):
    u, v = map(int, input().split())
    G[u].append(v+10**5)
    G[v].append(u+10**5)
    G[u+10**5].append(v)
    G[v+10**5].append(u)

que = []
heapq.heapify(que)

d_s = [10**10 for i in range(2*10**5+1)]
d_s[start] = 0
heapq.heappush(que, (0, start))
while que:
    cost, v = heapq.heappop(que)
    if d_s[v] < cost:
        continue

    for e in G[v]:
        if d_s[e] > d_s[v] + 1:
            d_s[e] = d_s[v] + 1
            heapq.heappush(que, (d_s[e], e))

d_g = [10**10 for i in range(2*10**5+1)]
d_g[goal] = 0
heapq.heappush(que, (0, goal))
while que:
    cost, v = heapq.heappop(que)
    if d_g[v] < cost:
        continue

    for e in G[v]:
        if d_g[e] > d_g[v] + 1:
            d_g[e] = d_g[v] + 1
            heapq.heappush(que, (d_g[e], e))

is_accessible = [0 for i in range(N+1)]

for node in range(1, N+1):
    flag = False
    for i in range(2):
        for j in range(2):
            v = d_s[node + i*10**5] + d_g[node+j*10**5]
            if v <= P and v % 2 == P % 2:
                is_accessible[node] = 1

K = sum(is_accessible)
print(K)
for i in range(1, N+1):
    if is_accessible[i] == 1:
        print(i)
0