結果
問題 | No.1190 Points |
ユーザー | tamato |
提出日時 | 2020-08-24 21:43:49 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 515 ms / 2,000 ms |
コード長 | 2,443 bytes |
コンパイル時間 | 196 ms |
コンパイル使用メモリ | 82,576 KB |
実行使用メモリ | 124,152 KB |
最終ジャッジ日時 | 2024-11-06 10:45:23 |
合計ジャッジ時間 | 9,724 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
54,516 KB |
testcase_01 | AC | 43 ms
54,516 KB |
testcase_02 | AC | 44 ms
54,596 KB |
testcase_03 | AC | 267 ms
107,036 KB |
testcase_04 | AC | 262 ms
100,196 KB |
testcase_05 | AC | 249 ms
99,688 KB |
testcase_06 | AC | 350 ms
113,260 KB |
testcase_07 | AC | 352 ms
114,976 KB |
testcase_08 | AC | 399 ms
124,152 KB |
testcase_09 | AC | 444 ms
116,452 KB |
testcase_10 | AC | 418 ms
123,236 KB |
testcase_11 | AC | 370 ms
105,912 KB |
testcase_12 | AC | 433 ms
121,220 KB |
testcase_13 | AC | 317 ms
99,712 KB |
testcase_14 | AC | 87 ms
86,044 KB |
testcase_15 | AC | 471 ms
115,484 KB |
testcase_16 | AC | 137 ms
81,548 KB |
testcase_17 | AC | 453 ms
111,072 KB |
testcase_18 | AC | 238 ms
89,164 KB |
testcase_19 | AC | 88 ms
86,960 KB |
testcase_20 | AC | 292 ms
96,532 KB |
testcase_21 | AC | 173 ms
87,440 KB |
testcase_22 | AC | 100 ms
88,388 KB |
testcase_23 | AC | 515 ms
115,348 KB |
testcase_24 | AC | 491 ms
115,948 KB |
testcase_25 | AC | 350 ms
105,684 KB |
testcase_26 | AC | 143 ms
93,972 KB |
testcase_27 | AC | 361 ms
105,544 KB |
ソースコード
mod = 1000000007 eps = 10**-9 def main(): import sys from collections import deque input = sys.stdin.buffer.readline N, M, P = map(int, input().split()) S, G = map(int, input().split()) adj = [[] for _ in range(N+1)] for _ in range(M): a, b = map(int, input().split()) adj[a].append(b) adj[b].append(a) def dist(v0): que = deque() que.append(v0) seen = [10**10] * (N+1) seen[v0] = 0 par = [0] * (N+1) child = [[] for _ in range(N+1)] seq = [] V = set() while que: v = que.popleft() seq.append(v) for u in adj[v]: if seen[u] == 10**10: seen[u] = seen[v] + 1 par[u] = v child[v].append(u) que.append(u) elif seen[u] == seen[v]: V.add(u) V.add(v) elif seen[u] == seen[v] + 1: child[v].append(u) seq.reverse() add = [10**11] * (N+1) for v in V: add[v] = 1 que.append(v) while que: vv = que.popleft() for u in child[vv]: if add[u] == 1: continue que.append(u) add[u] = 1 while True: updated = 0 for v in seq: val = add[v] for u in child[v]: val = min(val, add[u] + 2) if add[v] != val: updated = 1 add[v] = val seq.reverse() for v in seq: for u in child[v]: if add[u] > add[v]: updated = 1 add[u] = min(add[u], add[v]) seq.reverse() if not updated: break return seen, add ds, adds = dist(S) dg, addg = dist(G) ans = [] for v in range(1, N+1): if ds[v] + dg[v] <= P: if (ds[v] + dg[v])%2 == P%2: ans.append(v) else: if ds[v] + dg[v] + min(adds[v], addg[v]) <= P: ans.append(v) if ans: print(len(ans)) for a in ans: print(a) else: print(-1) if __name__ == '__main__': main()