Ejemplo n.º 1
0
Archivo: 6.cs Proyecto: qifanyyy/CLCDSA
            string Solve(int K, int N, List <int> keys, List <Chest> chests)
            {
                VisitedList = new List <Visited> [1 << VisitedHashLen];
                for (int i = 0; i < VisitedList.Length; i++)
                {
                    VisitedList[i] = new List <Visited>();
                }
                List <List <int> > keyToChest = new List <List <int> >();

                for (int i = 0; i < chests.Count; i++)
                {
                    int k = chests[i].ToOpen;
                    while (k >= keyToChest.Count)
                    {
                        keyToChest.Add(new List <int>());
                    }
                    keyToChest[k].Add(i);
                }
                Visited v = new Visited();

                v.Init();
                List <int> order = Search(keys, chests, keyToChest, v, 0);

                if (order != null)
                {
                    return(string.Join(" ", order));
                }
                return("IMPOSSIBLE");
            }