結果

問題 No.1190 Points
ユーザー AndrewKAndrewK
提出日時 2020-08-01 10:54:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,395 bytes
コンパイル時間 105 ms
コンパイル使用メモリ 10,876 KB
実行使用メモリ 49,972 KB
最終ジャッジ日時 2023-09-22 02:54:44
合計ジャッジ時間 25,446 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,156 KB
testcase_01 AC 15 ms
8,220 KB
testcase_02 AC 16 ms
8,180 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1,653 ms
45,584 KB
testcase_10 AC 612 ms
48,880 KB
testcase_11 AC 1,178 ms
35,680 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
inf = 3*(10 ^ 18)
n, m, p = map(int, input().split())
s, g = map(int, input().split())
road = [[0 for j in range(0)] for i in range(n + 1)]
kyo_s = [[inf for j in range(2)] for i in range(n + 1)]
kyo_g = [[inf for j in range(2)] for i in range(n + 1)]
kyo_s[s][0] = 0
kyo_g[g][0] = 0
ans = []
for _ in range(m):
    u, v = map(int, input().split())
    road[u].append(v)
    road[v].append(u)

q = []
heapq.heapify(q)
heapq.heappush(q, [0, s])
while len(q):
    k = heapq.heappop(q)
    cnt = k[0]
    x = k[1]
    if kyo_s[x][cnt & 1] < cnt:
        continue
    cnt += 1
    for i in road[x]:
        if kyo_s[i][cnt & 1] > cnt:
            heapq.heappush(q, [cnt, i])
            kyo_s[i][cnt & 1] = cnt

heapq.heappush(q, [0, g])
while len(q):
    k = heapq.heappop(q)
    cnt = k[0]
    x = k[1]
    if kyo_g[x][cnt & 1] < cnt:
        continue
    cnt += 1
    for i in road[x]:
        if kyo_g[i][cnt & 1] > cnt:
            heapq.heappush(q, [cnt, i])
            kyo_g[i][cnt & 1] = cnt

for i in range(1, n+1):
    if p & 1:
        odd = min(kyo_s[i][0] + kyo_g[i][1], kyo_s[i][1] + kyo_g[i][0])
        if odd <= p:
            ans.append(i)
    else:
        even = min(kyo_s[i][0] + kyo_g[i][0], kyo_s[i][1] + kyo_g[i][1])
        if even <= p:
            ans.append(i)

if (len(ans) == 0):
    print(-1)
else:
    print(len(ans))
    for i in ans:
        print(i)
0