結果
問題 | No.1190 Points |
ユーザー | Chihaya_chan |
提出日時 | 2020-09-03 00:01:19 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,439 bytes |
コンパイル時間 | 358 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 193,748 KB |
最終ジャッジ日時 | 2024-11-22 02:31:44 |
合計ジャッジ時間 | 37,578 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
52,736 KB |
testcase_01 | AC | 42 ms
52,608 KB |
testcase_02 | AC | 42 ms
52,864 KB |
testcase_03 | AC | 1,181 ms
154,908 KB |
testcase_04 | AC | 1,053 ms
140,492 KB |
testcase_05 | AC | 913 ms
134,424 KB |
testcase_06 | AC | 1,403 ms
187,808 KB |
testcase_07 | AC | 1,480 ms
176,212 KB |
testcase_08 | AC | 1,753 ms
189,528 KB |
testcase_09 | AC | 1,906 ms
183,412 KB |
testcase_10 | AC | 1,762 ms
190,012 KB |
testcase_11 | AC | 1,366 ms
149,596 KB |
testcase_12 | AC | 1,956 ms
190,272 KB |
testcase_13 | AC | 1,388 ms
137,584 KB |
testcase_14 | AC | 388 ms
155,796 KB |
testcase_15 | TLE | - |
testcase_16 | AC | 349 ms
96,244 KB |
testcase_17 | TLE | - |
testcase_18 | AC | 933 ms
112,172 KB |
testcase_19 | AC | 475 ms
182,360 KB |
testcase_20 | AC | 1,291 ms
127,628 KB |
testcase_21 | AC | 599 ms
126,860 KB |
testcase_22 | AC | 553 ms
182,860 KB |
testcase_23 | TLE | - |
testcase_24 | TLE | - |
testcase_25 | AC | 1,538 ms
183,980 KB |
testcase_26 | AC | 799 ms
183,640 KB |
testcase_27 | AC | 1,571 ms
183,908 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)