示例#1
0
        public static IList <string> Answer(IList <string> inputs)
        {
            var gis   = new AdjacencyListGraphInput(inputs);
            var g     = gis.ToEdges();
            var start = gis.NextAsIndex();


            var path = ShortestPath(start, g.Item1, g.Item2.ToList());

            return(path.Distance.Values
                   .Select(v =>
            {
                switch (v)
                {
                case NegativeInfinity:
                    return "-";

                case PositiveInfinity:
                    return "*";

                default:
                    return v.ToString();
                }
            })
                   .ToArray());
        }
示例#2
0
        public static IList <string> Answer(IList <string> inputs)
        {
            var gis = new AdjacencyListGraphInput(inputs);
            var g   = gis.ToEdges();

            var answer = HasNegativeCycle(g.Item1, g.Item2.ToList()) ? "1" : "0";

            return(new[] { answer });
        }