結果
問題 | No.1190 Points |
ユーザー | Chihaya_chan |
提出日時 | 2020-09-03 00:01:19 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,903 ms / 2,000 ms |
コード長 | 1,439 bytes |
コンパイル時間 | 286 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 193,772 KB |
最終ジャッジ日時 | 2024-05-01 20:13:04 |
合計ジャッジ時間 | 30,241 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
52,864 KB |
testcase_01 | AC | 39 ms
53,248 KB |
testcase_02 | AC | 37 ms
52,608 KB |
testcase_03 | AC | 943 ms
154,848 KB |
testcase_04 | AC | 850 ms
140,428 KB |
testcase_05 | AC | 755 ms
134,332 KB |
testcase_06 | AC | 1,206 ms
187,664 KB |
testcase_07 | AC | 1,274 ms
176,204 KB |
testcase_08 | AC | 1,461 ms
189,656 KB |
testcase_09 | AC | 1,627 ms
183,408 KB |
testcase_10 | AC | 1,558 ms
189,384 KB |
testcase_11 | AC | 1,160 ms
149,588 KB |
testcase_12 | AC | 1,542 ms
189,764 KB |
testcase_13 | AC | 1,098 ms
137,572 KB |
testcase_14 | AC | 332 ms
155,952 KB |
testcase_15 | AC | 1,843 ms
176,424 KB |
testcase_16 | AC | 298 ms
96,100 KB |
testcase_17 | AC | 1,654 ms
192,436 KB |
testcase_18 | AC | 711 ms
111,720 KB |
testcase_19 | AC | 406 ms
182,360 KB |
testcase_20 | AC | 967 ms
127,772 KB |
testcase_21 | AC | 494 ms
126,804 KB |
testcase_22 | AC | 447 ms
182,728 KB |
testcase_23 | AC | 1,903 ms
181,852 KB |
testcase_24 | AC | 1,851 ms
193,772 KB |
testcase_25 | AC | 1,236 ms
183,848 KB |
testcase_26 | AC | 591 ms
183,648 KB |
testcase_27 | AC | 1,264 ms
183,656 KB |
ソースコード
# Points # 拡張ダイクストラ import heapq N, M, P = map(int, input().split()) start, goal = map(int, input().split()) G = {(i, j): [] for i in range(1, N+1) for j in range(2)} for i in range(M): u, v = map(int, input().split()) G[(u, 0)].append((v, 1)) G[(v, 0)].append((u, 1)) G[(u, 1)].append((v, 0)) G[(v, 1)].append((u, 0)) que = [] heapq.heapify(que) d_s = {(i, j): 10**10 for i in range(1, N+1) for j in range(2)} d_s[(start, 0)] = 0 heapq.heappush(que, (0, (start, 0))) while que: cost, v = heapq.heappop(que) if d_s[v] < cost: continue for e in G[v]: if d_s[e] > d_s[v] + 1: d_s[e] = d_s[v] + 1 heapq.heappush(que, (d_s[e], e)) d_g = {(i, j): 10**10 for i in range(1, N+1) for j in range(2)} d_g[(goal, 0)] = 0 heapq.heappush(que, (0, (goal, 0))) while que: cost, v = heapq.heappop(que) if d_g[v] < cost: continue for e in G[v]: if d_g[e] > d_g[v] + 1: d_g[e] = d_g[v] + 1 heapq.heappush(que, (d_g[e], e)) is_accessible = [0 for i in range(N+1)] for node in range(1, N+1): for i in range(2): for j in range(2): v = d_s[(node, i)] + d_g[(node, j)] if v <= P and v % 2 == P % 2: is_accessible[node] = 1 K = sum(is_accessible) if K == 0: print(-1) exit() print(K) for i in range(1, N+1): if is_accessible[i] == 1: print(i)