Пример #1
0
    static void Main()
    {
        int[]    input   = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        Tyoten[] tyotens = new Tyoten[input[0]];
        for (int i = 0; i < tyotens.Length; i++)
        {
            tyotens[i] = new Tyoten((i + 1).ToString());
        }

        for (int i = 0; i < input[1]; i++)
        {
            int[] hen = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            Tyoten.Connect(tyotens[hen[0] - 1], tyotens[hen[1] - 1]);
        }

        int count = 0;

        List <Route> routes = new List <Route>();

        routes.Add(new Route(tyotens[0]));
        while (routes.Count > 0)
        {
            if (routes[0].UsedTyotens.Count == tyotens.Length)
            {
                ++count;
                routes.RemoveAt(0);
            }
            else
            {
                IEnumerable <Route> route = routes[0].GetNextRoutes();
                if (route.Count() == 0)
                {
                    routes.RemoveAt(0);
                }
                else
                {
                    routes.RemoveAt(0);
                    routes.AddRange(route);
                }
            }
        }

        WriteLine(count);
        ReadKey();
    }
Пример #2
0
 public Route(Route route, Tyoten NextPoint)
 {
     UsedTyotens = new List <Tyoten>(route.UsedTyotens);
     NowPoint    = NextPoint;
     UsedTyotens.Add(NextPoint);
 }
Пример #3
0
 public Route(Tyoten NowPoint)
 {
     UsedTyotens = new List <Tyoten>();
     UsedTyotens.Add(NowPoint);
     this.NowPoint = NowPoint;
 }
Пример #4
0
 public static void Connect(Tyoten a, Tyoten b)
 {
     a.ConnentedTyoten.Add(b);
     b.ConnentedTyoten.Add(a);
 }