結果

問題 No.468 役に立つ競技プログラミング実践編
ユーザー ヒッキープログラミングするスレ GitHub ガチヒッキープログラミングするスレ GitHub ガチ
提出日時 2016-12-18 07:49:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 857 ms / 2,000 ms
コード長 953 bytes
コンパイル時間 381 ms
コンパイル使用メモリ 87,352 KB
実行使用メモリ 167,116 KB
最終ジャッジ日時 2023-08-21 00:34:28
合計ジャッジ時間 13,597 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,296 KB
testcase_01 AC 73 ms
71,160 KB
testcase_02 AC 72 ms
71,308 KB
testcase_03 AC 77 ms
71,492 KB
testcase_04 AC 72 ms
71,476 KB
testcase_05 AC 76 ms
71,316 KB
testcase_06 AC 76 ms
71,100 KB
testcase_07 AC 76 ms
71,468 KB
testcase_08 AC 79 ms
71,300 KB
testcase_09 AC 78 ms
71,448 KB
testcase_10 AC 79 ms
71,516 KB
testcase_11 AC 77 ms
71,644 KB
testcase_12 AC 77 ms
71,420 KB
testcase_13 AC 77 ms
71,400 KB
testcase_14 AC 129 ms
78,696 KB
testcase_15 AC 128 ms
78,864 KB
testcase_16 AC 128 ms
78,880 KB
testcase_17 AC 128 ms
78,724 KB
testcase_18 AC 129 ms
78,556 KB
testcase_19 AC 129 ms
78,476 KB
testcase_20 AC 128 ms
78,508 KB
testcase_21 AC 131 ms
79,040 KB
testcase_22 AC 131 ms
78,668 KB
testcase_23 AC 131 ms
78,856 KB
testcase_24 AC 838 ms
166,616 KB
testcase_25 AC 846 ms
166,588 KB
testcase_26 AC 853 ms
167,004 KB
testcase_27 AC 809 ms
166,540 KB
testcase_28 AC 808 ms
166,444 KB
testcase_29 AC 825 ms
166,936 KB
testcase_30 AC 849 ms
167,020 KB
testcase_31 AC 857 ms
167,116 KB
testcase_32 AC 835 ms
166,620 KB
testcase_33 AC 848 ms
167,112 KB
testcase_34 AC 284 ms
132,260 KB
testcase_35 AC 94 ms
75,252 KB
testcase_36 AC 76 ms
71,092 KB
権限があれば一括ダウンロードができます

ソースコード

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