結果
問題 | No.1480 Many Complete Graphs |
ユーザー | eijirou |
提出日時 | 2021-04-17 15:49:27 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 436 ms / 2,000 ms |
コード長 | 1,148 bytes |
コンパイル時間 | 168 ms |
コンパイル使用メモリ | 81,632 KB |
実行使用メモリ | 109,288 KB |
最終ジャッジ日時 | 2024-07-03 23:22:46 |
合計ジャッジ時間 | 17,958 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
52,352 KB |
testcase_01 | AC | 41 ms
52,736 KB |
testcase_02 | AC | 42 ms
52,480 KB |
testcase_03 | AC | 38 ms
52,736 KB |
testcase_04 | AC | 37 ms
52,480 KB |
testcase_05 | AC | 40 ms
52,480 KB |
testcase_06 | AC | 40 ms
52,480 KB |
testcase_07 | AC | 39 ms
52,972 KB |
testcase_08 | AC | 40 ms
52,992 KB |
testcase_09 | AC | 49 ms
61,824 KB |
testcase_10 | AC | 50 ms
62,044 KB |
testcase_11 | AC | 40 ms
53,376 KB |
testcase_12 | AC | 52 ms
62,464 KB |
testcase_13 | AC | 82 ms
82,360 KB |
testcase_14 | AC | 59 ms
72,448 KB |
testcase_15 | AC | 222 ms
87,368 KB |
testcase_16 | AC | 174 ms
83,892 KB |
testcase_17 | AC | 168 ms
82,996 KB |
testcase_18 | AC | 113 ms
80,208 KB |
testcase_19 | AC | 183 ms
82,768 KB |
testcase_20 | AC | 210 ms
83,844 KB |
testcase_21 | AC | 80 ms
81,216 KB |
testcase_22 | AC | 59 ms
70,912 KB |
testcase_23 | AC | 100 ms
83,420 KB |
testcase_24 | AC | 191 ms
84,632 KB |
testcase_25 | AC | 302 ms
92,488 KB |
testcase_26 | AC | 353 ms
95,768 KB |
testcase_27 | AC | 215 ms
85,248 KB |
testcase_28 | AC | 379 ms
107,520 KB |
testcase_29 | AC | 384 ms
108,800 KB |
testcase_30 | AC | 349 ms
105,472 KB |
testcase_31 | AC | 359 ms
107,136 KB |
testcase_32 | AC | 377 ms
109,288 KB |
testcase_33 | AC | 359 ms
105,856 KB |
testcase_34 | AC | 365 ms
108,672 KB |
testcase_35 | AC | 354 ms
105,856 KB |
testcase_36 | AC | 364 ms
106,440 KB |
testcase_37 | AC | 360 ms
106,624 KB |
testcase_38 | AC | 359 ms
106,036 KB |
testcase_39 | AC | 376 ms
106,752 KB |
testcase_40 | AC | 356 ms
106,872 KB |
testcase_41 | AC | 355 ms
106,284 KB |
testcase_42 | AC | 368 ms
107,948 KB |
testcase_43 | AC | 368 ms
107,216 KB |
testcase_44 | AC | 377 ms
105,916 KB |
testcase_45 | AC | 381 ms
107,904 KB |
testcase_46 | AC | 355 ms
107,392 KB |
testcase_47 | AC | 434 ms
98,684 KB |
testcase_48 | AC | 423 ms
98,092 KB |
testcase_49 | AC | 436 ms
97,820 KB |
testcase_50 | AC | 129 ms
91,008 KB |
testcase_51 | AC | 430 ms
98,276 KB |
testcase_52 | AC | 414 ms
102,216 KB |
testcase_53 | AC | 424 ms
101,424 KB |
testcase_54 | AC | 413 ms
102,144 KB |
testcase_55 | AC | 399 ms
101,332 KB |
testcase_56 | AC | 399 ms
101,832 KB |
testcase_57 | AC | 148 ms
92,192 KB |
testcase_58 | AC | 340 ms
97,708 KB |
evil_aftercontest.txt | AC | 590 ms
119,044 KB |
ソースコード
from heapq import heappush, heappop from sys import stdin input = stdin.readline inf = 1 << 60 def main(): n, m = map(int, input().split()) edges = [[] for _ in range(n+m)] for i in range(n, n+m): k, c, *s = map(int, input().split()) for j in s: edges[j-1].append((c, i)) edges[i].append(j-1) # Dijkstra heap = [] heappush(heap, (0, 0, 0)) costs = [(inf,inf)] * (n+m) while heap: cost, rem, i = heappop(heap) if costs[i] < (cost,rem): continue if i < n: for c, j in edges[i]: new_cost = (cost + c + (i+1)//2, i+1 & 1) if new_cost < costs[j]: costs[j] = new_cost heappush(heap, (new_cost[0],new_cost[1],j)) else: for j in edges[i]: new_cost = (cost + (j+rem+2)//2, 0) if new_cost < costs[j]: costs[j] = new_cost heappush(heap, (new_cost[0],new_cost[1],j)) if costs[n-1] == (inf, inf): print(-1) else: print(costs[n-1][0]) main()