結果
問題 | No.1995 CHIKA Road |
ユーザー | とりゐ |
提出日時 | 2022-07-01 21:35:00 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,132 ms / 2,000 ms |
コード長 | 739 bytes |
コンパイル時間 | 285 ms |
コンパイル使用メモリ | 87,064 KB |
実行使用メモリ | 192,076 KB |
最終ジャッジ日時 | 2023-08-17 08:57:11 |
合計ジャッジ時間 | 19,653 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 90 ms
71,836 KB |
testcase_01 | AC | 93 ms
71,344 KB |
testcase_02 | AC | 89 ms
71,528 KB |
testcase_03 | AC | 92 ms
71,732 KB |
testcase_04 | AC | 92 ms
71,736 KB |
testcase_05 | AC | 101 ms
76,712 KB |
testcase_06 | AC | 230 ms
83,576 KB |
testcase_07 | AC | 335 ms
96,132 KB |
testcase_08 | AC | 110 ms
76,900 KB |
testcase_09 | AC | 104 ms
76,448 KB |
testcase_10 | AC | 360 ms
88,592 KB |
testcase_11 | AC | 1,132 ms
192,076 KB |
testcase_12 | AC | 442 ms
120,504 KB |
testcase_13 | AC | 457 ms
111,484 KB |
testcase_14 | AC | 476 ms
112,704 KB |
testcase_15 | AC | 935 ms
178,492 KB |
testcase_16 | AC | 252 ms
86,168 KB |
testcase_17 | AC | 536 ms
118,704 KB |
testcase_18 | AC | 800 ms
147,236 KB |
testcase_19 | AC | 804 ms
147,736 KB |
testcase_20 | AC | 509 ms
114,448 KB |
testcase_21 | AC | 474 ms
112,200 KB |
testcase_22 | AC | 759 ms
140,824 KB |
testcase_23 | AC | 334 ms
95,712 KB |
testcase_24 | AC | 676 ms
131,984 KB |
testcase_25 | AC | 276 ms
87,972 KB |
testcase_26 | AC | 388 ms
101,972 KB |
testcase_27 | AC | 659 ms
131,168 KB |
testcase_28 | AC | 465 ms
112,196 KB |
testcase_29 | AC | 764 ms
146,860 KB |
testcase_30 | AC | 260 ms
87,680 KB |
testcase_31 | AC | 220 ms
82,568 KB |
testcase_32 | AC | 287 ms
89,952 KB |
testcase_33 | AC | 638 ms
129,360 KB |
testcase_34 | AC | 221 ms
83,692 KB |
testcase_35 | AC | 367 ms
96,984 KB |
testcase_36 | AC | 415 ms
105,888 KB |
testcase_37 | AC | 732 ms
140,432 KB |
testcase_38 | AC | 560 ms
119,984 KB |
testcase_39 | AC | 216 ms
82,452 KB |
ソースコード
from heapq import heappush, heappop INF=10**18 def dijkstra(): dist=defaultdict(lambda:INF) hq=[(0,1)] dist[1]=0 seen=set() while hq: w,v=heappop(hq) if dist[v]<w: continue seen.add(v) for to,cost in edge[v]: if to not in seen and dist[v]+cost<dist[to]: dist[to]=dist[v]+cost heappush(hq,(dist[to],to)) return dist from collections import defaultdict edge=defaultdict(list) n,m=map(int,input().split()) town=set([1,n]) for _ in range(m): a,b=map(int,input().split()) town.add(a) town.add(b) edge[a].append((b,2*b-2*a-1)) town=sorted(list(town)) k=len(town) for i in range(k-1): edge[town[i]].append((town[i+1],2*(town[i+1]-town[i]))) #print(edge) d=dijkstra() print(d[n])