結果
問題 |
No.468 役に立つ競技プログラミング実践編
|
ユーザー |
|
提出日時 | 2016-12-18 10:49:37 |
言語 | PyPy2 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,017 bytes |
コンパイル時間 | 398 ms |
コンパイル使用メモリ | 77,180 KB |
実行使用メモリ | 249,736 KB |
最終ジャッジ日時 | 2024-12-14 08:04:21 |
合計ジャッジ時間 | 39,063 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 21 TLE * 10 |
other | AC * 6 |
ソースコード
#!/usr/bin/python2 # -*- coding: utf-8 -*- # † from heapq import heappush, heappop n, m = map(int, raw_input().split()) G0 = [[] for i in range(n)] rG = [[] for i in range(n)] for _ in xrange(m): a, b, c = map(int, raw_input().split()) G0[a].append((b, c)) rG[b].append((a, c)) cost0 = [-1] * n # cost0[n] cost0[0] = 0 que0 = [] heappush(que0, [0, 0]) while len(que0): c, v = heappop(que0) if c < cost0[v]: continue for e in G0[v]: if cost0[e[0]] < cost0[v] + e[1]: cost0[e[0]] = cost0[v] + e[1] heappush(que0, [cost0[e[0]], e[0]]) rcost = [-1] * n # rcost[n] rcost[n-1] = 0 rq = [] heappush(rq, [0, n-1]) while len(rq): c, v = heappop(rq) if c < rcost[v]: continue for e in rG[v]: if rcost[e[0]] < rcost[v] + e[1]: rcost[e[0]] = rcost[v] + e[1] heappush(rq, [rcost[e[0]], e[0]]) days = cost0[n-1] cnt = sum(cost0[i] != days - rcost[i] for i in xrange(n)) print '{} {}/{}'.format(days, cnt, n)