package adv2016; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class N468_2 { InputStream is; PrintWriter out; String INPUT = ""; void solve() { int n = ni(), m = ni(); int[] from = new int[m]; int[] to = new int[m]; int[] w = new int[m]; for(int i = 0;i < m;i++){ from[i] = ni(); to[i] = ni(); w[i] = ni(); } int[][][] g = packWD(n, from, to, w); int[][][] ig = packWD(n, to, from, w); int[] indeg = new int[n]; for(int i = 0;i < m;i++){ indeg[to[i]]++; } TaggedSimpleMinHeapL h = new TaggedSimpleMinHeapL(n); h.add(0, 0L); long[] ends = new long[n]; int[] ord = new int[n]; int p = 0; while(h.size() > 0){ int cur = h.mintag(); h.poll(); ord[p++] = cur; for(int[] e : g[cur]){ ends[e[0]] = Math.max(ends[e[0]], ends[cur] + e[1]); indeg[e[0]]--; if(indeg[e[0]] == 0){ h.add(e[0], ends[e[0]]); } } } out.print(ends[n-1] + " "); boolean[] cri = new boolean[n]; cri[n-1] = true; for(int i = p-1;i >= 0;i--){ if(!cri[ord[i]])continue; for(int[] e : ig[ord[i]]){ if(ends[ord[i]] == ends[e[0]] + e[1]){ cri[e[0]] = true; } } } int incri = 0; for(int i = 0;i < n;i++){ if(!cri[i])incri++; } out.println(incri + "/" + n); } public static class TaggedSimpleMinHeapL { public long[] a; public int[] tags; public int n; public int pos; public static final long INF = Long.MAX_VALUE; public TaggedSimpleMinHeapL(int m) { n = m+1; a = new long[n]; tags = new int[n]; Arrays.fill(a, INF); Arrays.fill(tags, -1); pos = 1; } public TaggedSimpleMinHeapL(long[] in) { n = in.length+1; if((n&1)==1)n++; a = new long[n]; tags = new int[n]; pos = 1+in.length; // Arrays.fill(a, INF); a[0] = a[n-1] = a[n-2] = INF; System.arraycopy(in, 0, a, 1, in.length); for(int i = 0;i < in.length;i++){ tags[1+i] = i; } for(int t = pos/2-1;t >= 1;t--){ for(int c = t;2*c < pos;){ int smaller = a[2*c] < a[2*c+1] ? 2*c : 2*c+1; if(a[smaller] < a[c]){ {long d = a[c]; a[c] = a[smaller]; a[smaller] = d;} {int d = tags[c]; tags[c] = tags[smaller]; tags[smaller] = d;} c = smaller; }else{ break; } } } } public void add(int tag, long x) { a[pos] = x; tags[pos] = tag; pos++; for(int c = pos-1, p = c>>>1;p >= 1 && a[c] < a[p];c>>>=1, p>>>=1){ {long d = a[p]; a[p] = a[c]; a[c] = d;} {int d = tags[p]; tags[p] = tags[c]; tags[c] = d;} } } public long poll() { if(pos == 1)return INF; pos--; long ret = a[1]; a[1] = a[pos]; a[pos] = INF; tags[1] = tags[pos]; tags[pos] = -1; for(int c = 1;2*c < pos;){ int smaller = a[2*c] < a[2*c+1] ? 2*c : 2*c+1; if(a[smaller] < a[c]){ {long d = a[c]; a[c] = a[smaller]; a[smaller] = d;} {int d = tags[c]; tags[c] = tags[smaller]; tags[smaller] = d;} c = smaller; }else{ break; } } return ret; } public long min() { return a[1]; } public int mintag() { return tags[1]; } public int size() { return pos-1; } } public static int[][][] packWD(int n, int[] from, int[] to, int[] w) { int[][][] g = new int[n][][]; int[] p = new int[n]; for (int f : from) p[f]++; for (int i = 0; i < n; i++) g[i] = new int[p[i]][2]; for (int i = 0; i < from.length; i++) { --p[from[i]]; g[from[i]][p[from[i]]][0] = to[i]; g[from[i]][p[from[i]]][1] = w[i]; } return g; } void run() throws Exception { is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes()); out = new PrintWriter(System.out); long s = System.currentTimeMillis(); solve(); out.flush(); if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms"); // Thread t = new Thread(null, null, "~", Runtime.getRuntime().maxMemory()){ // @Override // public void run() { // long s = System.currentTimeMillis(); // solve(); // out.flush(); // if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms"); // } // }; // t.start(); // t.join(); } public static void main(String[] args) throws Exception { new N468_2().run(); } private byte[] inbuf = new byte[1024]; public int lenbuf = 0, ptrbuf = 0; private int readByte() { if(lenbuf == -1)throw new InputMismatchException(); if(ptrbuf >= lenbuf){ ptrbuf = 0; try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); } if(lenbuf <= 0)return -1; } return inbuf[ptrbuf++]; } private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); } private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; } private double nd() { return Double.parseDouble(ns()); } private char nc() { return (char)skip(); } private String ns() { int b = skip(); StringBuilder sb = new StringBuilder(); while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ') sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } private char[] ns(int n) { char[] buf = new char[n]; int b = skip(), p = 0; while(p < n && !(isSpaceChar(b))){ buf[p++] = (char)b; b = readByte(); } return n == p ? buf : Arrays.copyOf(buf, p); } private int[] na(int n) { int[] a = new int[n]; for(int i = 0;i < n;i++)a[i] = ni(); return a; } private long[] nal(int n) { long[] a = new long[n]; for(int i = 0;i < n;i++)a[i] = nl(); return a; } private char[][] nm(int n, int m) { char[][] map = new char[n][]; for(int i = 0;i < n;i++)map[i] = ns(m); return map; } private int[][] nmi(int n, int m) { int[][] map = new int[n][]; for(int i = 0;i < n;i++)map[i] = na(m); return map; } private int ni() { return (int)nl(); } private long nl() { long num = 0; int b; boolean minus = false; while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')); if(b == '-'){ minus = true; b = readByte(); } while(true){ if(b >= '0' && b <= '9'){ num = num * 10 + (b - '0'); }else{ return minus ? -num : num; } b = readByte(); } } private static void tr(Object... o) { System.out.println(Arrays.deepToString(o)); } }