#include using namespace std; #define rep(i,a,b) for(int i=a;i> E[101010]; //----------------------------------------------------------------- typedef vector vi; typedef vector vvi; bool visit(const vector& g, int v, vector& order, vector& color) { color[v] = 1; for (int u : g[v]) { if (color[u] == 2) continue; if (color[u] == 1) return false; if (!visit(g, u, order, color)) return false; } order.push_back(v); color[v] = 2; return true; } bool TopologicalSort(const vector& g, vector& order) { int n = g.size(); vector color(n); for (int u = 0; u < n; u++) if (!color[u] && !visit(g, u, order, color)) return false; reverse(order.begin(), order.end()); return true; } //----------------------------------------------------------------- #define INF INT_MAX/2 int dpmax[101010], dpmin[101010];; int main() { cin >> N >> M; vvi g(N); rep(i, 0, M) { scanf("%d%d%d", &A[i], &B[i], &C[i]); E[A[i]].push_back({ B[i], C[i] }); g[A[i]].push_back(B[i]); } // toposo vi order; TopologicalSort(g, order); rep(i, 0, 101010) { dpmax[i] = 0; dpmin[i] = INF; } dpmax[0] = dpmin[0] = 0; rep(_i, 0, order.size()) { int i = order[_i]; for (auto p : E[i]) { int j = p.first; int c = p.second; dpmax[j] = max(dpmax[j], dpmax[i] + c); } } dpmin[N - 1] = dpmax[N - 1]; reverse(order.begin(), order.end()); rep(_i, 0, order.size()) { int i = order[_i]; for (auto p : E[i]) { int j = p.first; int c = p.second; dpmin[i] = min(dpmin[i], dpmin[j] - c); } } //rep(i, 0, N) printf("< %d / %d >\n", dpmax[i], dpmin[i]); printf("%d ", dpmax[N - 1]); int ans = N; rep(i, 0, N) if (dpmin[i] == dpmax[i]) ans--; printf("%d/%d\n", ans, N); }