結果

問題 No.1190 Points
ユーザー AndrewKAndrewK
提出日時 2020-08-01 11:19:57
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,398 bytes
コンパイル時間 350 ms
コンパイル使用メモリ 86,984 KB
実行使用メモリ 139,072 KB
最終ジャッジ日時 2023-09-22 03:40:57
合計ジャッジ時間 28,949 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
71,216 KB
testcase_01 AC 83 ms
71,368 KB
testcase_02 AC 86 ms
71,284 KB
testcase_03 AC 785 ms
103,980 KB
testcase_04 AC 681 ms
99,376 KB
testcase_05 AC 643 ms
99,756 KB
testcase_06 AC 912 ms
108,564 KB
testcase_07 AC 949 ms
112,860 KB
testcase_08 AC 1,238 ms
117,660 KB
testcase_09 AC 1,579 ms
135,688 KB
testcase_10 AC 1,280 ms
119,620 KB
testcase_11 AC 1,235 ms
120,252 KB
testcase_12 AC 1,440 ms
127,572 KB
testcase_13 AC 1,258 ms
112,644 KB
testcase_14 AC 217 ms
96,480 KB
testcase_15 TLE -
testcase_16 AC 299 ms
85,168 KB
testcase_17 AC 1,826 ms
132,408 KB
testcase_18 AC 744 ms
95,480 KB
testcase_19 AC 231 ms
100,284 KB
testcase_20 AC 1,047 ms
105,368 KB
testcase_21 AC 442 ms
93,768 KB
testcase_22 AC 276 ms
102,816 KB
testcase_23 TLE -
testcase_24 TLE -
testcase_25 AC 1,172 ms
120,100 KB
testcase_26 AC 341 ms
107,168 KB
testcase_27 AC 1,189 ms
120,432 KB
権限があれば一括ダウンロードができます

ソースコード

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 % 2] < cnt:
        continue
    cnt += 1
    for i in road[x]:
        if kyo_s[i][cnt % 2] > cnt:
            heapq.heappush(q, [cnt, i])
            kyo_s[i][cnt % 2] = cnt

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

for i in range(1, n+1):
    if p % 2:
        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