結果

問題 No.468 役に立つ競技プログラミング実践編
ユーザー H3PO4H3PO4
提出日時 2020-11-24 21:38:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 748 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 10,844 KB
実行使用メモリ 118,740 KB
最終ジャッジ日時 2023-10-01 01:14:14
合計ジャッジ時間 28,201 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,236 KB
testcase_01 AC 17 ms
8,176 KB
testcase_02 AC 18 ms
8,164 KB
testcase_03 AC 19 ms
7,972 KB
testcase_04 AC 18 ms
8,284 KB
testcase_05 AC 18 ms
8,012 KB
testcase_06 AC 19 ms
7,972 KB
testcase_07 AC 19 ms
8,080 KB
testcase_08 AC 19 ms
8,124 KB
testcase_09 AC 19 ms
7,984 KB
testcase_10 AC 19 ms
8,124 KB
testcase_11 AC 18 ms
8,028 KB
testcase_12 AC 19 ms
8,076 KB
testcase_13 AC 19 ms
7,972 KB
testcase_14 AC 32 ms
9,176 KB
testcase_15 AC 32 ms
9,204 KB
testcase_16 AC 34 ms
9,224 KB
testcase_17 AC 32 ms
9,172 KB
testcase_18 AC 32 ms
9,272 KB
testcase_19 AC 33 ms
9,212 KB
testcase_20 AC 32 ms
9,220 KB
testcase_21 AC 32 ms
9,320 KB
testcase_22 AC 32 ms
9,204 KB
testcase_23 AC 32 ms
9,132 KB
testcase_24 TLE -
testcase_25 TLE -
testcase_26 TLE -
testcase_27 TLE -
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 TLE -
testcase_34 AC 1,187 ms
95,964 KB
testcase_35 AC 27 ms
8,992 KB
testcase_36 AC 18 ms
7,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import graphlib

input = sys.stdin.buffer.readline

N, M = map(int, input().split())
# Python 3.9 の新機能
ts = graphlib.TopologicalSorter()
parents, children = [[] for _ in range(N)], [[] for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    # to, fromの順なので注意
    ts.add(b, a)
    parents[b].append((a, c))
    children[a].append((b, c))

tps = tuple(ts.static_order())
earliest, latest = [0] * N, [0] * N
for x in tps:
    earliest[x] = max((earliest[p] + v for p, v in parents[x]), default=0)
for x in reversed(tps):
    latest[x] = max((latest[c] + v for c, v in children[x]), default=0)

T = earliest[N - 1]
P = sum(earliest[x] + latest[x] != T for x in range(N))
print(f'{T} {P}/{N}')
0