結果

問題 No.1190 Points
ユーザー lloyzlloyz
提出日時 2023-11-03 01:47:41
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 969 bytes
コンパイル時間 348 ms
コンパイル使用メモリ 81,812 KB
実行使用メモリ 98,444 KB
最終ジャッジ日時 2023-11-03 01:47:52
合計ジャッジ時間 10,180 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
55,640 KB
testcase_01 AC 41 ms
55,640 KB
testcase_02 AC 43 ms
55,640 KB
testcase_03 AC 250 ms
90,672 KB
testcase_04 AC 237 ms
88,988 KB
testcase_05 AC 248 ms
91,872 KB
testcase_06 AC 295 ms
94,220 KB
testcase_07 AC 317 ms
98,444 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 111 ms
83,168 KB
testcase_15 WA -
testcase_16 AC 104 ms
79,164 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 98 ms
81,840 KB
testcase_20 WA -
testcase_21 AC 136 ms
84,360 KB
testcase_22 AC 137 ms
87,792 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 274 ms
92,312 KB
testcase_26 AC 205 ms
92,248 KB
testcase_27 AC 264 ms
91,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict, deque

n, m, p = map(int, input().split())
s, g = map(int, input().split())
s -= 1
g -= 1
G = defaultdict(list)
for _ in range(m):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    G[u].append(v)
    G[v].append(u)

INF = 10**18
D_s = [INF for _ in range(n)]
D_s[s] = 0
Que = deque([s])
while Que:
    cp = Que.popleft()
    cc = D_s[cp]
    nc = cc + 1
    for np in G[cp]:
        if nc >= D_s[np]:
            continue
        D_s[np] = nc
        Que.append(np)
D_g = [INF for _ in range(n)]
D_g[g] = 0
Que = deque([g])
while Que:
    cp = Que.popleft()
    cc = D_g[cp]
    nc = cc + 1
    for np in G[cp]:
        if nc >= D_g[np]:
            continue
        D_g[np] = nc
        Que.append(np)
ans = []
for i in range(n):
    res = D_s[i] + D_g[i]
    dif = p - res
    if dif >= 0 and dif % 2 == 0:
        ans.append(i + 1)
if len(ans) == 0:
    print(-1)
else:
    print(len(ans))
    print(*ans, sep='\n')
0