結果

問題 No.1190 Points
ユーザー AndrewKAndrewK
提出日時 2020-08-01 11:18:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,398 bytes
コンパイル時間 309 ms
コンパイル使用メモリ 10,868 KB
実行使用メモリ 55,792 KB
最終ジャッジ日時 2023-09-22 03:39:18
合計ジャッジ時間 22,451 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,120 KB
testcase_01 AC 20 ms
8,204 KB
testcase_02 AC 19 ms
8,188 KB
testcase_03 AC 900 ms
36,284 KB
testcase_04 AC 803 ms
33,204 KB
testcase_05 AC 752 ms
31,840 KB
testcase_06 AC 1,205 ms
42,708 KB
testcase_07 AC 1,276 ms
47,076 KB
testcase_08 AC 1,794 ms
55,792 KB
testcase_09 AC 1,933 ms
45,520 KB
testcase_10 AC 1,756 ms
49,460 KB
testcase_11 AC 1,447 ms
35,740 KB
testcase_12 AC 1,886 ms
47,544 KB
testcase_13 AC 1,554 ms
31,404 KB
testcase_14 AC 320 ms
29,812 KB
testcase_15 TLE -
testcase_16 AC 205 ms
15,664 KB
testcase_17 TLE -
testcase_18 AC 1,092 ms
23,096 KB
testcase_19 AC 370 ms
36,152 KB
testcase_20 AC 1,461 ms
27,828 KB
testcase_21 AC 463 ms
25,276 KB
testcase_22 AC 470 ms
38,476 KB
testcase_23 TLE -
testcase_24 TLE -
testcase_25 AC 1,629 ms
47,644 KB
testcase_26 AC 701 ms
45,104 KB
testcase_27 AC 1,595 ms
47,600 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