結果

問題 No.1601 With Animals into Institute
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-07-11 09:16:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,200 ms / 3,000 ms
コード長 712 bytes
コンパイル時間 517 ms
コンパイル使用メモリ 86,976 KB
実行使用メモリ 179,232 KB
最終ジャッジ日時 2023-09-14 20:05:51
合計ジャッジ時間 32,052 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,316 KB
testcase_01 AC 72 ms
71,408 KB
testcase_02 AC 72 ms
71,080 KB
testcase_03 AC 178 ms
80,076 KB
testcase_04 AC 177 ms
80,180 KB
testcase_05 AC 179 ms
80,116 KB
testcase_06 AC 2,041 ms
178,012 KB
testcase_07 AC 2,013 ms
178,288 KB
testcase_08 AC 2,056 ms
178,348 KB
testcase_09 AC 2,070 ms
176,288 KB
testcase_10 AC 2,143 ms
179,104 KB
testcase_11 AC 2,200 ms
176,452 KB
testcase_12 AC 2,114 ms
176,044 KB
testcase_13 AC 2,131 ms
179,232 KB
testcase_14 AC 2,134 ms
178,312 KB
testcase_15 AC 2,099 ms
178,364 KB
testcase_16 AC 2,070 ms
177,948 KB
testcase_17 AC 2,138 ms
177,596 KB
testcase_18 AC 180 ms
80,472 KB
testcase_19 AC 187 ms
80,100 KB
testcase_20 AC 191 ms
80,760 KB
testcase_21 AC 183 ms
80,544 KB
testcase_22 AC 189 ms
80,856 KB
testcase_23 AC 184 ms
80,208 KB
testcase_24 AC 181 ms
80,208 KB
testcase_25 AC 182 ms
79,972 KB
testcase_26 AC 188 ms
80,308 KB
testcase_27 AC 74 ms
71,348 KB
testcase_28 AC 72 ms
71,212 KB
testcase_29 AC 72 ms
71,296 KB
testcase_30 AC 73 ms
71,196 KB
testcase_31 AC 73 ms
71,024 KB
testcase_32 AC 73 ms
71,424 KB
testcase_33 AC 73 ms
71,328 KB
testcase_34 AC 72 ms
71,368 KB
testcase_35 AC 73 ms
71,472 KB
testcase_36 AC 74 ms
71,380 KB
testcase_37 AC 71 ms
71,324 KB
testcase_38 AC 74 ms
71,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m=map(int,input().split())
abcx=[list(map(int,input().split())) for _ in range(m)]
g=[[] for _ in range(n)]
for a,b,c,x in abcx:
  a,b=a-1,b-1
  g[a].append([b,c,x])
  g[b].append([a,c,x])
inf=float('inf')
seen=[inf]*(2*n)
todo=[[0,2*n-1]]
seen[-1]=0
from heapq import heappop,heappush
while todo:
  d,v=heappop(todo)
  if v>=n:
    for nv,nd,x in g[v-n]:
      if x==1:
        if seen[nv]>d+nd:
          seen[nv]=d+nd
          heappush(todo,[d+nd,nv])
      else:
        if seen[nv+n]>d+nd:
          seen[nv+n]=d+nd
          heappush(todo,[d+nd,nv+n])
  else:
    for nv,nd,x in g[v]:
      if seen[nv]>d+nd:
        seen[nv]=d+nd
        heappush(todo,[d+nd,nv])
for i in range(n-1):
  print(seen[i])

0