結果

問題 No.1190 Points
ユーザー buey_tbuey_t
提出日時 2023-04-23 11:54:43
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,108 bytes
コンパイル時間 348 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 105,984 KB
最終ジャッジ日時 2024-04-25 09:02:04
合計ジャッジ時間 9,085 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
85,248 KB
testcase_01 WA -
testcase_02 AC 134 ms
85,120 KB
testcase_03 AC 287 ms
101,504 KB
testcase_04 AC 258 ms
97,920 KB
testcase_05 AC 262 ms
99,968 KB
testcase_06 AC 303 ms
101,760 KB
testcase_07 AC 341 ms
105,984 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

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)

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













0