結果
問題 | No.1601 With Animals into Institute |
ユーザー | mkawa2 |
提出日時 | 2023-05-19 15:23:45 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,163 ms / 3,000 ms |
コード長 | 1,555 bytes |
コンパイル時間 | 558 ms |
コンパイル使用メモリ | 87,056 KB |
実行使用メモリ | 120,936 KB |
最終ジャッジ日時 | 2023-08-22 20:46:04 |
合計ジャッジ時間 | 21,896 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 77 ms
71,084 KB |
testcase_01 | AC | 78 ms
71,248 KB |
testcase_02 | AC | 78 ms
71,092 KB |
testcase_03 | AC | 166 ms
79,052 KB |
testcase_04 | AC | 167 ms
79,204 KB |
testcase_05 | AC | 170 ms
78,964 KB |
testcase_06 | AC | 1,031 ms
119,772 KB |
testcase_07 | AC | 1,078 ms
120,108 KB |
testcase_08 | AC | 1,041 ms
118,724 KB |
testcase_09 | AC | 1,078 ms
119,976 KB |
testcase_10 | AC | 1,103 ms
120,124 KB |
testcase_11 | AC | 1,042 ms
118,928 KB |
testcase_12 | AC | 1,083 ms
120,004 KB |
testcase_13 | AC | 1,042 ms
119,548 KB |
testcase_14 | AC | 1,125 ms
120,056 KB |
testcase_15 | AC | 1,163 ms
119,316 KB |
testcase_16 | AC | 1,102 ms
120,936 KB |
testcase_17 | AC | 1,059 ms
118,896 KB |
testcase_18 | AC | 166 ms
79,252 KB |
testcase_19 | AC | 172 ms
79,704 KB |
testcase_20 | AC | 171 ms
79,256 KB |
testcase_21 | AC | 171 ms
79,232 KB |
testcase_22 | AC | 175 ms
79,096 KB |
testcase_23 | AC | 169 ms
78,596 KB |
testcase_24 | AC | 169 ms
79,020 KB |
testcase_25 | AC | 166 ms
79,132 KB |
testcase_26 | AC | 175 ms
78,740 KB |
testcase_27 | AC | 78 ms
71,296 KB |
testcase_28 | AC | 80 ms
71,192 KB |
testcase_29 | AC | 79 ms
71,348 KB |
testcase_30 | AC | 80 ms
71,244 KB |
testcase_31 | AC | 80 ms
71,464 KB |
testcase_32 | AC | 80 ms
71,380 KB |
testcase_33 | AC | 80 ms
71,228 KB |
testcase_34 | AC | 80 ms
71,160 KB |
testcase_35 | AC | 81 ms
71,264 KB |
testcase_36 | AC | 79 ms
71,236 KB |
testcase_37 | AC | 80 ms
70,992 KB |
testcase_38 | AC | 80 ms
71,288 KB |
ソースコード
import sys # sys.setrecursionlimit(200005) # sys.set_int_max_str_digits(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = (1 << 63)-1 # md = 10**9+7 md = 998244353 from heapq import * n,m=LI() s=n to=[[] for _ in range(n)] for _ in range(m): u,v,c,x=LI() u,v=u-1,v-1 if x: to+=[[],[]] to[u].append((s,c)) to[s].append((v,0)) to[v].append((s+1,c)) to[s+1].append((u,0)) s+=2 else: to[u].append((v,c)) to[v].append((u,c)) d1=[inf]*s d1[n-1]=0 hp=[(0,n-1)] while hp: d,u=heappop(hp) if d>d1[u]:continue for v,c in to[u]: nd=d+c if nd>=d1[v]:continue d1[v]=nd heappush(hp,(nd,v)) d2=[inf]*s hp=[] for u in range(n,s): d2[u]=d1[u] heappush(hp,(d2[u],u)) while hp: d,u=heappop(hp) if d>d2[u]:continue for v,c in to[u]: nd=d+c if nd>=d2[v]:continue d2[v]=nd heappush(hp,(nd,v)) print(*d2[:n-1],sep="\n")