#include #include #include #include #define repeat(i,n) for (int i = 0; (i) < int(n); ++(i)) using namespace std; template using reversed_priority_queue = priority_queue, greater >; template void setmax(T & a, T const & b) { if (a < b) a = b; } template void setmin(T & a, T const & b) { if (b < a) a = b; } int main() { int n, m; cin >> n >> m; vector > > g(n); vector > > h(n); repeat (i,m) { int a, b, c; cin >> a >> b >> c; g[a].emplace_back(b, c); h[b].emplace_back(a, c); } vector fast(n); { reversed_priority_queue > que; vector done(n); que.emplace(0, 0); while (not que.empty()) { int a = que.top().second; que.pop(); for (auto it : g[a]) { int b, c; tie(b, c) = it; setmax(fast[b], fast[a] + c); done[b] += 1; if (done[b] == h[b].size()) que.emplace(fast[b], b); } } } vector slow(n, fast[n-1]); { priority_queue > que; vector done(n); que.emplace(fast[n-1], n-1); while (not que.empty()) { int b = que.top().second; que.pop(); for (auto it : h[b]) { int a, c; tie(a, c) = it; setmin(slow[a], slow[b] - c); done[a] += 1; if (done[a] == g[a].size()) que.emplace(slow[a], a); } } } int t = fast[n-1]; int p = 0; repeat (a,n) p += fast[a] < slow[a]; cout << t << ' ' << p << '/' << n << endl; return 0; }