結果
問題 | No.468 役に立つ競技プログラミング実践編 |
ユーザー | mkawa2 |
提出日時 | 2020-04-30 18:59:24 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 1,009 ms / 2,000 ms |
コード長 | 1,558 bytes |
コンパイル時間 | 169 ms |
コンパイル使用メモリ | 10,988 KB |
実行使用メモリ | 96,208 KB |
最終ジャッジ日時 | 2023-08-22 12:28:41 |
合計ジャッジ時間 | 14,467 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 20 ms
8,716 KB |
testcase_01 | AC | 20 ms
8,696 KB |
testcase_02 | AC | 20 ms
8,796 KB |
testcase_03 | AC | 20 ms
8,816 KB |
testcase_04 | AC | 19 ms
8,816 KB |
testcase_05 | AC | 21 ms
8,788 KB |
testcase_06 | AC | 21 ms
8,928 KB |
testcase_07 | AC | 21 ms
8,792 KB |
testcase_08 | AC | 21 ms
8,960 KB |
testcase_09 | AC | 21 ms
8,944 KB |
testcase_10 | AC | 21 ms
8,928 KB |
testcase_11 | AC | 21 ms
8,752 KB |
testcase_12 | AC | 21 ms
8,784 KB |
testcase_13 | AC | 20 ms
8,848 KB |
testcase_14 | AC | 26 ms
9,560 KB |
testcase_15 | AC | 27 ms
9,652 KB |
testcase_16 | AC | 27 ms
9,584 KB |
testcase_17 | AC | 27 ms
9,500 KB |
testcase_18 | AC | 28 ms
9,600 KB |
testcase_19 | AC | 28 ms
9,580 KB |
testcase_20 | AC | 28 ms
9,480 KB |
testcase_21 | AC | 27 ms
9,576 KB |
testcase_22 | AC | 28 ms
9,644 KB |
testcase_23 | AC | 27 ms
9,648 KB |
testcase_24 | AC | 1,005 ms
96,052 KB |
testcase_25 | AC | 1,004 ms
96,208 KB |
testcase_26 | AC | 1,007 ms
96,092 KB |
testcase_27 | AC | 999 ms
96,156 KB |
testcase_28 | AC | 1,004 ms
96,032 KB |
testcase_29 | AC | 1,009 ms
96,164 KB |
testcase_30 | AC | 1,000 ms
95,944 KB |
testcase_31 | AC | 1,001 ms
96,020 KB |
testcase_32 | AC | 1,007 ms
96,012 KB |
testcase_33 | AC | 995 ms
95,800 KB |
testcase_34 | AC | 286 ms
56,540 KB |
testcase_35 | AC | 23 ms
9,184 KB |
testcase_36 | AC | 20 ms
8,820 KB |
ソースコード
from itertools import * from bisect import * from collections import * from heapq import * import sys sys.setrecursionlimit(10 ** 6) def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def SI(): return sys.stdin.readline()[:-1] def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI1(rows_number): return [LI1() for _ in range(rows_number)] int1 = lambda x: int(x) - 1 def MI1(): return map(int1, sys.stdin.readline().split()) def LI1(): return list(map(int1, sys.stdin.readline().split())) p2D = lambda x: print(*x, sep="\n") dij = [(1, 0), (0, 1), (-1, 0), (0, -1)] def main(): n,m=MI() to=[[] for _ in range(n)] ot=[[] for _ in range(n)] for _ in range(m): u,v,c=MI() to[u].append((v,c)) ot[v].append((u,c)) # 最早結合点時刻 q=deque() deg=[0]*n fast=[0]*n q.append(0) while q: u=q.popleft() for v,c in to[u]: deg[v]+=1 if fast[u]+c>fast[v]:fast[v]=fast[u]+c if deg[v]==len(ot[v]):q.append(v) #print(fast) # 最遅結合点時刻 q=deque() deg=[0]*n slow=[fast[n-1]]*n q.append(n-1) while q: u=q.popleft() for v,c in ot[u]: deg[v]+=1 if slow[u]-c<slow[v]:slow[v]=slow[u]-c if deg[v]==len(to[v]):q.append(v) #print(slow) p=sum(fast[u]!=slow[u] for u in range(n)) print("{} {}/{}".format(fast[n-1],p,n)) main()