#include using namespace std; #define _p(...) (void)printf(__VA_ARGS__) #define forr(x,arr) for(auto&& x:arr) #define _overload3(_1,_2,_3,name,...) name #define _rep2(i,n) _rep3(i,0,n) #define _rep3(i,a,b) for(int i=int(a);i=int(a);i--) #define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__) #define all(x) (x).begin(), (x).end() #define bit(n) (1LL<<(n)) #define sz(x) ((int)(x).size()) #define fst first #define snd second using ll=long long;using pii=pair; using vb=vector;using vs=vector; using vi=vector;using vvi=vector;using vvvi=vector; using vl=vector;using vvl=vector;using vvvl=vector; using vd=vector;using vvd=vector;using vvvd=vector; using vpii=vector;using vvpii=vector;using vvvpii=vector; templateT read(){T t;cin>>t;return t;} templateostream&operator<<(ostream&o,const pair&p){o<<'('< topological_sort(vector > &E) { int N = E.size(); vector used(N); vector indeg(N); for (auto &es : E) for (pii &vc : es) indeg[vc.fst]++; vector ret; ret.reserve(N); queue q; for (int i = 0; i < N; i++) { if (indeg[i] == 0 && !used[i]) { q.push(i); used[i] = 1; while (!q.empty()) { int cur = q.front(); q.pop(); ret.push_back(cur); for (pii &nexc : E[cur]) { int nex = nexc.fst; indeg[nex]--; if (indeg[nex] == 0 && !used[nex]) { used[nex] = 1; q.push(nex); } } } } } return *max_element(indeg.begin(), indeg.end()) == 0 ? ret : vector(); } void Main() { int n = read(); int m = read(); vvpii E(n), F(n);; rep(i, m) { int u = read(); int v = read(); int w = read(); E[u].emplace_back(v, w); F[v].emplace_back(u, w); } vi V = topological_sort(E); const int inf = 1e9; vi D(n, -inf); D[V[0]] = 0; forr(v, V) { forr(uc, E[v]) { int u = uc.fst; int c = uc.snd; D[u] = max(D[u], D[v] + c); } } int T = D[V[n-1]]; vb C(n); C[V[n-1]] = 1; reverse(all(V)); forr(v, V) { if (!C[v]) continue; forr(uc, F[v]) { int u = uc.fst; int c = uc.snd; if (D[u] + c == D[v]) { C[u] = 1; } } } int P = n; forr(c, C) P -= c; _p("%d %d/%d\n", T, P, n); } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }