結果

問題 No.1190 Points
ユーザー buey_tbuey_t
提出日時 2023-04-23 12:03:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 523 ms / 2,000 ms
コード長 2,484 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 127,360 KB
最終ジャッジ日時 2024-04-25 09:07:17
合計ジャッジ時間 10,648 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
84,864 KB
testcase_01 AC 124 ms
84,992 KB
testcase_02 AC 126 ms
84,992 KB
testcase_03 AC 359 ms
112,472 KB
testcase_04 AC 312 ms
109,344 KB
testcase_05 AC 293 ms
109,952 KB
testcase_06 AC 362 ms
116,864 KB
testcase_07 AC 376 ms
121,728 KB
testcase_08 AC 421 ms
127,360 KB
testcase_09 AC 411 ms
123,136 KB
testcase_10 AC 415 ms
127,104 KB
testcase_11 AC 330 ms
113,536 KB
testcase_12 AC 411 ms
124,928 KB
testcase_13 AC 365 ms
109,400 KB
testcase_14 AC 174 ms
98,944 KB
testcase_15 AC 522 ms
124,544 KB
testcase_16 AC 179 ms
95,360 KB
testcase_17 AC 452 ms
120,704 KB
testcase_18 AC 256 ms
96,768 KB
testcase_19 AC 182 ms
103,552 KB
testcase_20 AC 323 ms
104,420 KB
testcase_21 AC 201 ms
94,592 KB
testcase_22 AC 212 ms
112,128 KB
testcase_23 AC 523 ms
125,312 KB
testcase_24 AC 487 ms
125,440 KB
testcase_25 AC 376 ms
113,152 KB
testcase_26 AC 247 ms
112,640 KB
testcase_27 AC 355 ms
113,408 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]*2 for _ in range(N+1)]

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

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

seen2 = [[INF]*2 for _ in range(N+1)]

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

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

ans.sort()

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

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













0