結果
| 問題 |
No.1190 Points
|
| コンテスト | |
| ユーザー |
buey_t
|
| 提出日時 | 2023-04-23 10:12:37 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,641 bytes |
| コンパイル時間 | 333 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 309,808 KB |
| 最終ジャッジ日時 | 2024-11-07 18:11:57 |
| 合計ジャッジ時間 | 4,989 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | TLE * 1 -- * 24 |
ソースコード
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回まで探索すればいいけど
それまでに通った辺をどうやって管理するか
重複していいならリストでいいのか
'''
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,[]))
ans = set()
while len(Q) > 0:
pos = Q[0][0]
ls = deepcopy(Q[0][1])
Q.popleft()
ls.append(pos)
if len(ls) > P+1:
break
if len(ls) == P+1:
if pos == Go:
for i in ls:
ans.add(i)
continue
for nx in G[pos]:
Q.append((nx,ls))
if len(ans) == 0:
print(-1)
exit()
print(len(ans))
ans = list(ans)
ans.sort()
for a in ans:
print(a)
buey_t