結果

問題 No.468 役に立つ競技プログラミング実践編
ユーザー ヒッキープログラミングするスレ GitHub ガチヒッキープログラミングするスレ GitHub ガチ
提出日時 2016-12-18 07:49:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 953 bytes
コンパイル時間 449 ms
コンパイル使用メモリ 10,792 KB
実行使用メモリ 124,456 KB
最終ジャッジ日時 2023-08-21 00:33:59
合計ジャッジ時間 5,664 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
15,280 KB
testcase_01 AC 17 ms
8,364 KB
testcase_02 AC 16 ms
8,228 KB
testcase_03 AC 18 ms
8,436 KB
testcase_04 AC 16 ms
8,232 KB
testcase_05 AC 18 ms
8,488 KB
testcase_06 AC 18 ms
8,404 KB
testcase_07 AC 18 ms
8,464 KB
testcase_08 AC 18 ms
8,448 KB
testcase_09 AC 18 ms
8,344 KB
testcase_10 AC 18 ms
8,500 KB
testcase_11 AC 18 ms
8,316 KB
testcase_12 AC 17 ms
8,396 KB
testcase_13 AC 18 ms
8,448 KB
testcase_14 AC 35 ms
9,372 KB
testcase_15 AC 35 ms
9,316 KB
testcase_16 AC 35 ms
9,428 KB
testcase_17 AC 35 ms
9,384 KB
testcase_18 AC 35 ms
9,400 KB
testcase_19 AC 35 ms
9,328 KB
testcase_20 AC 35 ms
9,480 KB
testcase_21 AC 35 ms
9,392 KB
testcase_22 AC 34 ms
9,360 KB
testcase_23 AC 35 ms
9,368 KB
testcase_24 TLE -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())

r = [[] for _ in range(n)]
s = [[] for _ in range(n)]
t1 = [[0, 0] for _ in range(n)]
t2 = [[0, 16000000] for _ in range(n)]

for _ in range(m):
    a, b, c = map(int, input().split())
    r[a].append([b, c])
    s[b].append([a, c])

tmp1 = set()
tmp1.add(0)
while len(tmp1) > 0:
    tmp2 = set()
    for a in tmp1:
        for b, c in r[a]:
            t1[b][1] = max(t1[b][1], t1[a][1] + c)
            t1[b][0] += 1
            if t1[b][0] == len(s[b]):
                tmp2.add(b)
    tmp1 = tmp2

t2[n - 1][1] = t1[n - 1][1]
tmp1 = set()
tmp1.add(n - 1)
while len(tmp1) > 0:
    tmp2 = set()
    for b in tmp1:
        for a, c in s[b]:
            t2[a][1] = min(t2[a][1], t2[b][1] - c)
            t2[a][0] += 1
            if t2[a][0] == len(r[a]):
                tmp2.add(a)
    tmp1 = tmp2

p = 0
for i in range(n):
    if t1[i][1] != t2[i][1]:
        p += 1

print('{0} {1}/{2}'.format(t1[n - 1][1], p, n))
0