コード例 #1
0
        static void Main(string[] args)
        {
            var        inputFile  = args.Length > 0 ? args[0] : @"..\..\..\Input\a_example.in";
            PizzaPlate pizzaPlate = loadData(inputFile);

            List <PizzaSlice> slices = pizzaPlate.PerformSlice();

            if (pizzaPlate.IsValidSlicing(slices) == false)
            {
                Console.WriteLine("ERROR: Invalid slicing");
            }

            Console.WriteLine("Max theoretical score: {0}", pizzaPlate.GetSize());
            int solutionScore = slices.Sum(item => item.GetSize());

            Console.WriteLine("Solution score: {0}", solutionScore);

            Bitmap bitmap = pizzaPlate.generateSlicingBitmap(slices);

            var outputFile  = Path.Combine(OutputFolder, Path.ChangeExtension(Path.GetFileName(inputFile), "out"));
            var outputImage = outputFile + ".png";

            bitmap.Save(outputImage, System.Drawing.Imaging.ImageFormat.Png);

            using (System.IO.StreamWriter sw = new System.IO.StreamWriter(outputFile))
            {
                sw.WriteLine(slices.Count);
                foreach (PizzaSlice slice in slices)
                {
                    sw.Write(slice.RowMin);
                    sw.Write(' ');
                    sw.Write(slice.ColumnMin);
                    sw.Write(' ');
                    sw.Write(slice.RowMax);
                    sw.Write(' ');
                    sw.Write(slice.ColumnMax);

                    sw.WriteLine();
                }
            }

            Process.Start(outputImage);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            PizzaPlate pizzaPlate = loadData(args[0]);

            List <PizzaSlice> slices = pizzaPlate.PerformSlice();

            if (pizzaPlate.IsValidSlicing(slices) == false)
            {
                Console.WriteLine("ERROR: Invalid slicing");
            }

            Console.WriteLine("Max theoretical score: {0}", pizzaPlate.GetSize());
            int solutionScore = slices.Sum(item => item.GetSize());

            Console.WriteLine("Solution score: {0}", solutionScore);

            Bitmap bitmap = pizzaPlate.generateSlicingBitmap(slices);

            bitmap.Save(args[0] + ".png", System.Drawing.Imaging.ImageFormat.Png);

            using (System.IO.StreamWriter sw = new System.IO.StreamWriter(args[0] + ".out"))
            {
                sw.WriteLine(slices.Count);
                foreach (PizzaSlice slice in slices)
                {
                    sw.Write(slice.RowMin);
                    sw.Write(' ');
                    sw.Write(slice.ColumnMin);
                    sw.Write(' ');
                    sw.Write(slice.RowMax);
                    sw.Write(' ');
                    sw.Write(slice.ColumnMax);

                    sw.WriteLine();
                }
            }
        }