結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,336 KB
testcase_01 AC 18 ms
8,316 KB
testcase_02 AC 17 ms
8,312 KB
testcase_03 AC 17 ms
8,292 KB
testcase_04 AC 17 ms
8,296 KB
testcase_05 AC 17 ms
8,444 KB
testcase_06 AC 18 ms
8,408 KB
testcase_07 AC 18 ms
8,304 KB
testcase_08 AC 18 ms
8,380 KB
testcase_09 AC 18 ms
8,284 KB
testcase_10 AC 19 ms
8,396 KB
testcase_11 AC 18 ms
8,360 KB
testcase_12 AC 18 ms
8,268 KB
testcase_13 AC 18 ms
8,268 KB
testcase_14 AC 34 ms
8,976 KB
testcase_15 AC 34 ms
9,008 KB
testcase_16 AC 34 ms
9,020 KB
testcase_17 AC 35 ms
8,988 KB
testcase_18 AC 34 ms
8,996 KB
testcase_19 AC 34 ms
9,096 KB
testcase_20 AC 35 ms
9,080 KB
testcase_21 AC 35 ms
9,152 KB
testcase_22 AC 34 ms
9,144 KB
testcase_23 AC 35 ms
9,112 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 804 ms
54,060 KB
testcase_35 AC 23 ms
8,808 KB
testcase_36 AC 17 ms
8,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

r = [[] for _ in range(n)]
s = [[] for _ in range(n)]
x1 = [0] * n
c1 = [0] * n
x2 = [0] * n
c2 = [16000000] * n
cost = {}

def ky(a, b):
    return a * 100000 + b

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

tmp1 = [0]
while len(tmp1) > 0:
    tmp2 = []
    for a in tmp1:
        ca = c1[a]
        for b in r[a]:
            c1[b] = max(c1[b], ca + cost[ky(a, b)])
            x1[b] += 1
            if x1[b] == len(s[b]):
                tmp2.append(b)
    tmp1 = tmp2

c2[n - 1] = c1[n - 1]
tmp1 = [n - 1]
while len(tmp1) > 0:
    tmp2 = []
    for b in tmp1:
        cb = c2[b]
        for a in s[b]:
            c2[a] = min(c2[a], cb - cost[ky(a, b)])
            x2[a] += 1
            if x2[a] == len(r[a]):
                tmp2.append(a)
    tmp1 = tmp2

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

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