Esempio n. 1
0
        public static IList <string> Answer(IList <string> inputs)
        {
            var gi    = new GraphInput(inputs);
            var graph = gi.ToUndirectedAdjacencyGraph();
            //Console.WriteLine(graph);

            var answer = new BreadthFirstSearchWithBipartiteDetection(graph).IsBipartite() ? "1" : "0";

            return(new[] { answer });
        }
Esempio n. 2
0
        public static IList <string> Answer(IList <string> inputs)
        {
            var gi    = new GraphInput(inputs);
            var graph = gi.ToUndirectedAdjacencyGraph();
            //Console.WriteLine(graph);

            var points = gi.NextAsEdge();
            var path   = new BreadthFirstSearch(graph)
                         .ShortestPath(points.Left, points.Right);

            var answer = path.Any() ? path.Count.ToString() : "-1";

            return(new[] { answer });
        }