結果
| 問題 | No.468 役に立つ競技プログラミング実践編 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-12-18 18:57:08 |
| 言語 | PyPy2 (7.3.20) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 845 bytes |
| 記録 | |
| コンパイル時間 | 181 ms |
| コンパイル使用メモリ | 80,896 KB |
| 実行使用メモリ | 84,864 KB |
| 最終ジャッジ日時 | 2026-05-25 02:44:30 |
| 合計ジャッジ時間 | 7,105 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 21 TLE * 1 -- * 9 |
| other | AC * 3 -- * 3 |
ソースコード
#!/usr/bin/python2
# -*- coding: utf-8 -*-
# †
n, m = map(int, raw_input().split())
G0 = []
rG = []
for _ in xrange(m):
a, b, c = map(int, raw_input().split())
G0.append([a, b, -c])
rG.append([b, a, -c])
cost0 = [1] * n # cost0[n]
cost0[0] = 0
while True:
update = False
for e in G0:
if cost0[e[0]] != 1 and cost0[e[1]] > cost0[e[0]] + e[2]:
cost0[e[1]] = cost0[e[0]] + e[2]
update = True
if not update:
break
days = -cost0[n-1]
rcost = [1] * n
rcost[n-1] = 0
while True:
update = False
for e in rG:
if rcost[e[0]] != 1 and rcost[e[1]] > rcost[e[0]] + e[2]:
rcost[e[1]] = rcost[e[0]] + e[2]
update = True
if not update:
break
cnt = sum(-cost0[i] != days + rcost[i] for i in xrange(n))
print '{} {}/{}'.format(days, cnt, n)