結果

問題 No.1190 Points
ユーザー 37zigen37zigen
提出日時 2020-08-27 01:04:15
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,010 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 128,000 KB
最終ジャッジ日時 2024-04-25 04:25:54
合計ジャッジ時間 15,692 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
67,200 KB
testcase_01 AC 73 ms
66,944 KB
testcase_02 AC 78 ms
67,328 KB
testcase_03 AC 641 ms
113,664 KB
testcase_04 AC 602 ms
106,368 KB
testcase_05 AC 547 ms
111,872 KB
testcase_06 AC 761 ms
116,224 KB
testcase_07 AC 842 ms
128,000 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 150 ms
88,320 KB
testcase_15 WA -
testcase_16 AC 191 ms
83,968 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 148 ms
90,240 KB
testcase_20 WA -
testcase_21 AC 248 ms
89,728 KB
testcase_22 AC 173 ms
92,288 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 522 ms
103,892 KB
testcase_26 AC 220 ms
95,360 KB
testcase_27 AC 502 ms
104,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import queue
N,M,P=map(int,input().split())
S,G=map(int,input().split())
g=[[] for _ in range(N+1)]
for i in range(M):
    u,v=map(int,input().split())
    g[u].append(v)
    g[v].append(u)

def bfs(src):
    INF=10**20
    dist=[[INF]*(N+1) for _ in range(2)]
    vis=[[False]*(N+1) for _ in range(2)]
    dist[0][src]=0
    q=queue.Queue()
    q.put(src)
    while not q.empty():
        cur=q.get()
        for dst in g[cur]:
            for i in range(2):
                nd=dist[i][cur]+1
                if dist[nd%2][dst]==INF:
                    dist[nd%2][dst]=nd
                    q.put(dst)
    return dist

dist_src=bfs(S)
dist_dst=bfs(G)
ans_set=set()
for i in range(N+1):
    find=False
    for j in range(2):
        for k in range(2):
            if (j+k)%2 != P%2:
                continue
            if dist_src[j][i]+dist_dst[k][i]<=P:
                ans_set.add(i)
ans=list(ans_set)
ans.sort()
if len(ans)==0:
    print(-1)
else:
    print(len(ans))
    for a in ans:
        print(a)
0