示例#1
0
        private static void RunTest(int test, TimeSpan testRepeatTime)
        {
            string filename = $"inputs\\{test}.txt";

            using (StreamReader input = new StreamReader(filename))
            {
                int      H           = int.Parse(input.ReadLine());
                string[] targetBoard = new string[H];
                for (int i = 0; i < H; ++i)
                {
                    targetBoard[i] = input.ReadLine();
                }
                int costLantern  = int.Parse(input.ReadLine());
                int costMirror   = int.Parse(input.ReadLine());
                int costObstacle = int.Parse(input.ReadLine());

                int       maxMirrors   = int.Parse(input.ReadLine());
                int       maxObstacles = int.Parse(input.ReadLine());
                Stopwatch sw           = Stopwatch.StartNew();
                string[]  ret          = new CrystalLighting().placeItems(targetBoard, costLantern, costMirror, costObstacle, maxMirrors, maxObstacles);
                if (testRepeatTime > TimeSpan.Zero)
                {
                    while (sw.Elapsed < testRepeatTime)
                    {
                        ret = new CrystalLighting().placeItems(targetBoard, costLantern, costMirror, costObstacle, maxMirrors, maxObstacles);
                    }
                }
                Console.Error.WriteLine(string.Join("\n", ret));
            }
        }
示例#2
0
        private static void ExportOfflineData(string filename)
        {
            using (StreamWriter output = new StreamWriter(filename))
            {
                int      H           = int.Parse(Console.ReadLine());
                string[] targetBoard = new string[H];
                output.WriteLine(H);
                for (int i = 0; i < H; ++i)
                {
                    targetBoard[i] = Console.ReadLine();
                    output.WriteLine(targetBoard[i]);
                }
                int costLantern  = int.Parse(Console.ReadLine());
                int costMirror   = int.Parse(Console.ReadLine());
                int costObstacle = int.Parse(Console.ReadLine());
                output.WriteLine(costLantern);
                output.WriteLine(costMirror);
                output.WriteLine(costObstacle);

                int maxMirrors   = int.Parse(Console.ReadLine());
                int maxObstacles = int.Parse(Console.ReadLine());
                output.WriteLine(maxMirrors);
                output.WriteLine(maxObstacles);

                CrystalLighting cl  = new CrystalLighting();
                string[]        ret = new string[0];

                Console.WriteLine(ret.Length);
                for (int i = 0; i < ret.Length; ++i)
                {
                    Console.WriteLine(ret[i]);
                }
            }
        }
示例#3
0
        private static void OfflineTester()
        {
            int H = int.Parse(Console.ReadLine());

            string[] targetBoard = new string[H];
            for (int i = 0; i < H; ++i)
            {
                targetBoard[i] = Console.ReadLine();
            }
            int costLantern  = int.Parse(Console.ReadLine());
            int costMirror   = int.Parse(Console.ReadLine());
            int costObstacle = int.Parse(Console.ReadLine());

            int maxMirrors   = int.Parse(Console.ReadLine());
            int maxObstacles = int.Parse(Console.ReadLine());

            CrystalLighting cl = new CrystalLighting();

            string[] ret = cl.placeItems(targetBoard, costLantern, costMirror, costObstacle, maxMirrors, maxObstacles);

            Console.WriteLine(ret.Length);
            for (int i = 0; i < ret.Length; ++i)
            {
                Console.WriteLine(ret[i]);
            }
        }