using System; using System.Linq; using System.Collections.Generic; using System.Text; public class Program { public void Proc() { Reader.IsDebug = false; int[] inpt = Reader.ReadLine().Split(' ').Select(a=>int.Parse(a)).ToArray(); this.MemberCount = inpt[0]; this.PathCount = inpt[1]; this.maxCost = new long[this.MemberCount].Select(a=>(long)-1).ToArray(); this.minCost.Add(0,0); for(int i=0; iint.Parse(a)).ToArray(); if(!this.PathDic.ContainsKey(inpt[0])) { this.PathDic.Add(inpt[0], new Dictionary()); } this.PathDic[inpt[0]].Add(inpt[1], inpt[2]); if(!this.PathRev.ContainsKey(inpt[1])) { this.PathRev.Add(inpt[1], new Dictionary()); } this.PathRev[inpt[1]].Add(inpt[0], inpt[2]); } Queue que = new Queue(); que.Enqueue(0); while(que.Count > 0) { int cur = que.Dequeue(); long step = this.minCost[cur]; if(cur == this.MemberCount - 1) { continue; } this.PathDic[cur].ToList().ForEach(nv=>{ long nextStep = step + nv.Value; if(minCost.ContainsKey(nv.Key) && minCost[nv.Key] >= nextStep) { } else { minCost[nv.Key] = nextStep; que.Enqueue(nv.Key); } }); } this.maxCost[this.MemberCount-1] = minCost[this.MemberCount-1]; this.maxCost[0] = 0; que.Enqueue(this.MemberCount-1); while(que.Count > 0) { int cur = que.Dequeue(); long step = this.maxCost[cur]; foreach(KeyValuePair item in this.PathRev[cur]) { long nextStep = step-item.Value; if(item.Key == 0) { continue; } if(this.maxCost[item.Key] == -1 || maxCost[item.Key] > nextStep) { this.maxCost[item.Key] = nextStep; que.Enqueue(item.Key); } } } string ans = minCost[this.MemberCount-1] + " " + minCost.Count(a=>a.Value != maxCost[a.Key]) + "/" + this.MemberCount; Console.WriteLine(ans); } private Dictionary> PathDic = new Dictionary>(); private Dictionary> PathRev = new Dictionary>(); private Dictionary minCost = new Dictionary(); private long[] maxCost; private int MemberCount; private int PathCount; public class Reader { public static bool IsDebug = true; private static System.IO.StringReader SReader; private static string InitText = @" 8 12 0 1 3 0 2 3 1 3 3 1 4 3 2 3 3 2 4 3 3 5 3 3 6 3 4 5 3 4 6 3 5 7 3 6 7 3 "; public static string ReadLine() { if(IsDebug) { if(SReader == null) { SReader = new System.IO.StringReader(InitText.Trim()); } return SReader.ReadLine(); } else { return Console.ReadLine(); } } } public static void Main(string[] args) { Program prg = new Program(); prg.Proc(); } }