結果

問題 No.1190 Points
ユーザー buey_tbuey_t
提出日時 2023-04-23 11:55:08
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,119 bytes
コンパイル時間 456 ms
コンパイル使用メモリ 87,176 KB
実行使用メモリ 99,708 KB
最終ジャッジ日時 2023-08-07 15:18:50
合計ジャッジ時間 11,823 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 228 ms
82,352 KB
testcase_01 AC 227 ms
82,496 KB
testcase_02 AC 224 ms
82,456 KB
testcase_03 AC 405 ms
94,844 KB
testcase_04 AC 360 ms
92,084 KB
testcase_05 AC 345 ms
93,932 KB
testcase_06 AC 396 ms
95,972 KB
testcase_07 AC 404 ms
99,708 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 254 ms
86,924 KB
testcase_15 WA -
testcase_16 AC 258 ms
84,784 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 254 ms
88,748 KB
testcase_20 WA -
testcase_21 AC 276 ms
88,944 KB
testcase_22 AC 275 ms
92,636 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 345 ms
95,468 KB
testcase_26 AC 311 ms
95,024 KB
testcase_27 AC 350 ms
95,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import sqrt,sin,cos,tan,ceil,radians,floor,gcd,exp,log,log10,log2,factorial,fsum
from heapq import heapify, heappop, heappush
from bisect import bisect_left, bisect_right
from copy import deepcopy
import copy
import random
from collections import deque,Counter,defaultdict
from itertools import permutations,combinations
from decimal import Decimal,ROUND_HALF_UP
#tmp = Decimal(mid).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
from functools import lru_cache, reduce
#@lru_cache(maxsize=None)
from operator import add,sub,mul,xor,and_,or_,itemgetter
import sys
input = sys.stdin.readline
# .rstrip()
INF = 10**18
mod1 = 10**9+7
mod2 = 998244353

#DecimalならPython
#再帰ならPython!!!!!!!!!!!!!!!!!!!!!!!!!!


'''
dfsじゃないといけないかも
頂点Gまでの経路
まあ普通にP回まで探索すればいいけど
それまでに通った辺をどうやって管理するか
重複していいならリストでいいのか
逆に、P回移動したときにたどりつく頂点を列挙して
そこからbfsするとか
ちょっと厳しいか?

なるほど
前後からか
ちょっと答え見るの早いかもな
まあ今回はしょうがないとして
'''

N,M,P = map(int, input().split())
S,Go = 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)

Q = deque()
Q.append((S,0))

seen = [INF]*(N+1)

while len(Q) > 0:
    pos,cnt = Q.popleft()
    
    seen[pos] = cnt
    
    for nx in G[pos]:
        if seen[nx] == INF:
            Q.append((nx,cnt+1))
            seen[nx] = cnt+1

Q = deque()
Q.append((Go,0))

seen2 = [INF]*(N+1)

while len(Q) > 0:
    pos,cnt = Q.popleft()
    
    seen2[pos] = cnt
    
    for nx in G[pos]:
        if seen2[nx] == INF:
            Q.append((nx,cnt+1))
            seen2[nx] = cnt+1

ans = []
for i in range(1,N+1):
    if seen[i]+seen2[i] > P:
        continue
    if (seen[i]+seen2[i])%2 == P%2:
        ans.append(i)

ans.sort()

if len(ans) == 0:
    print(-1)
    exit()

print(len(ans))
for a in ans:
    print(a)













0