Exemplo n.º 1
0
        protected override ProblemOutput Solve(ProblemInput input)
        {
            if (input.Rows != 1000)
            {
                return(base.Solve(input));
            }
            int Factor = 10;

            input.Rows    /= Factor;
            input.Columns /= Factor;

            ProblemOutput basePit = base.Solve(input);

            ProblemOutput newOutput = new ProblemOutput();

            newOutput.Buildings = new List <OutputBuilding>();
            foreach (var item in basePit.Buildings.ToList())
            {
                for (int i = 0; i < Factor; i++)
                {
                    for (int j = 0; j < Factor; j++)
                    {
                        newOutput.Buildings.Add(new OutputBuilding()
                        {
                            Coordinate = new MatrixCoordinate(item.Coordinate.Row + i * input.Rows,
                                                              item.Coordinate.Column + j * input.Columns),
                            ProjectNumber = item.ProjectNumber
                        });
                    }
                }
            }

            return(newOutput);
        }
Exemplo n.º 2
0
        private static bool CanPutInside(ProblemInput prob)
        {
            bool canPutInside = false;

            foreach (var currProject in prob.BuildingProjects)
            {
                foreach (var insideProjects in prob.BuildingProjects)
                {
                    for (int row = 0; row < currProject.Plan.GetLength(0); row++)
                    {
                        for (int col = 0; col < currProject.Plan.GetLength(1); col++)
                        {
                            bool isSuspect = true;
                            for (int i = 0; i <= insideProjects.Plan.GetLength(0) && isSuspect; i++)
                            {
                                for (int j = 0; j <= insideProjects.Plan.GetLength(1) && isSuspect; j++)
                                {
                                    int rowToCheck = row + i;
                                    int colToCheck = col + i;

                                    if (!InMatrix(rowToCheck, colToCheck, currProject.Plan) ||
                                        currProject.Plan[rowToCheck, colToCheck])
                                    {
                                        isSuspect = false;
                                        break;
                                    }
                                }
                            }

                            if (isSuspect)
                            {
                                canPutInside = true;
                            }
                        }
                    }
                }
            }

            return(canPutInside);
        }