結果

問題 No.1190 Points
ユーザー mkawa2mkawa2
提出日時 2021-07-16 09:40:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,133 ms / 2,000 ms
コード長 1,331 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 10,964 KB
実行使用メモリ 53,128 KB
最終ジャッジ日時 2023-09-19 05:52:07
合計ジャッジ時間 18,826 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,880 KB
testcase_01 AC 20 ms
8,644 KB
testcase_02 AC 19 ms
8,644 KB
testcase_03 AC 532 ms
34,456 KB
testcase_04 AC 471 ms
31,708 KB
testcase_05 AC 417 ms
30,144 KB
testcase_06 AC 681 ms
40,100 KB
testcase_07 AC 751 ms
44,444 KB
testcase_08 AC 787 ms
53,128 KB
testcase_09 AC 885 ms
43,796 KB
testcase_10 AC 768 ms
46,768 KB
testcase_11 AC 640 ms
34,876 KB
testcase_12 AC 844 ms
44,932 KB
testcase_13 AC 662 ms
30,092 KB
testcase_14 AC 229 ms
27,824 KB
testcase_15 AC 1,088 ms
45,492 KB
testcase_16 AC 104 ms
15,088 KB
testcase_17 AC 1,013 ms
43,724 KB
testcase_18 AC 460 ms
21,948 KB
testcase_19 AC 284 ms
33,440 KB
testcase_20 AC 600 ms
26,868 KB
testcase_21 AC 255 ms
23,900 KB
testcase_22 AC 365 ms
35,716 KB
testcase_23 AC 1,129 ms
46,760 KB
testcase_24 AC 1,133 ms
46,844 KB
testcase_25 AC 810 ms
44,028 KB
testcase_26 AC 528 ms
42,048 KB
testcase_27 AC 805 ms
44,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**16
md = 998244353
# md = 10**9+7

from collections import deque

n, m, p = LI()
s, g = LI1()
to = [[] for _ in range(n)]
for _ in range(m):
    u, v = LI1()
    to[u].append(v)
    to[v].append(u)

def bfs(s):
    dist = [[inf]*2 for _ in range(n)]
    dist[s][0] = 0
    q = deque()
    q.append((s, 0))
    while q:
        u, p = q.popleft()
        d = dist[u][p]
        for v in to[u]:
            if dist[v][1-p] == inf:
                dist[v][1-p] = d+1
                q.append((v, 1-p))
    return dist

ds = bfs(s)
dg = bfs(g)
parity = p & 1
ans = []
for u in range(n):
    if ds[u][0]+dg[u][parity] <= p or ds[u][1]+dg[u][1-parity] <= p:
        ans.append(u+1)

if ans:
    print(len(ans))
    for a in ans: print(a)
else:
    print(-1)
0