結果

問題 No.1190 Points
ユーザー ああいいああいい
提出日時 2022-02-23 11:48:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 448 ms / 2,000 ms
コード長 1,077 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 87,220 KB
実行使用メモリ 118,968 KB
最終ジャッジ日時 2023-09-14 04:08:52
合計ジャッジ時間 9,693 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
71,236 KB
testcase_01 AC 89 ms
71,484 KB
testcase_02 AC 85 ms
71,484 KB
testcase_03 AC 327 ms
102,204 KB
testcase_04 AC 251 ms
98,224 KB
testcase_05 AC 256 ms
101,252 KB
testcase_06 AC 327 ms
105,448 KB
testcase_07 AC 348 ms
114,748 KB
testcase_08 AC 352 ms
117,556 KB
testcase_09 AC 345 ms
114,160 KB
testcase_10 AC 362 ms
118,968 KB
testcase_11 AC 294 ms
104,052 KB
testcase_12 AC 373 ms
115,876 KB
testcase_13 AC 294 ms
98,232 KB
testcase_14 AC 143 ms
89,312 KB
testcase_15 AC 415 ms
115,120 KB
testcase_16 AC 139 ms
83,504 KB
testcase_17 AC 379 ms
110,932 KB
testcase_18 AC 230 ms
87,712 KB
testcase_19 AC 142 ms
96,476 KB
testcase_20 AC 275 ms
93,708 KB
testcase_21 AC 176 ms
91,196 KB
testcase_22 AC 174 ms
97,688 KB
testcase_23 AC 448 ms
118,956 KB
testcase_24 AC 435 ms
118,532 KB
testcase_25 AC 324 ms
108,840 KB
testcase_26 AC 223 ms
107,444 KB
testcase_27 AC 310 ms
108,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

N,M,P = map(int,input().split())
S,GG = map(int,input().split())
G = [[] for _ in range(N+1)]
for _ in range(M):
    u,v = map(int,input().split())
    G[u].append(v)
    G[v].append(u)
inf = 10 ** 10
ds = [[inf] * 2 for _ in range(N+1)]
dg = [[inf] * 2 for _ in range(N+1)]
ds[S][0] = 0
dg[GG][0] = 0
from collections import deque
q = deque()
q.append((S,0))
while q:
    now,flag = q.popleft()
    for v in G[now]:
        if ds[v][1-flag] == inf:
            ds[v][1-flag] = ds[now][flag] + 1
            q.append((v,1-flag))
q.append((GG,0))
while q:
    now,flag = q.popleft()
    for v in G[now]:
        if dg[v][1-flag] == inf:
            dg[v][1-flag] = dg[now][flag] + 1
            q.append((v,1-flag))

ans = []
if P % 2 == 0:
    for i in range(1,N+1):
        if ds[i][0] + dg[i][0] <= P or ds[i][1] + dg[i][1] <= P:
            ans.append(i)
else:
    for i in range(1,N+1):
        if ds[i][1] + dg[i][0] <= P or ds[i][0] + dg[i][1] <= P:
            ans.append(i)
if len(ans) == 0:
    print(-1)
else:
    print(len(ans))
    print(*ans,sep="\n")
0