コード例 #1
0
ファイル: Program.cs プロジェクト: xoposhiy/icfpc2016
        static void Main(string[] args)
        {
            if (args.Contains("--yura"))
            {
                ShowIntro("SolveWithProjectionSolverRunner");

                for (var iteration = 0;; iteration++)
                {
                    if (iteration > 0 || args.Contains("-d"))
                    {
                        DownloadNewProblems();
                    }

                    Console.WriteLine("Solving...");
                    repo.GetAllNotSolvedPerfectly()
                    .OrderBy(EstimateDifficulty)
                    .AsParallel().WithDegreeOfParallelism(8)
                    .ForAll(problemSpec =>
                    {
                        Console.WriteLine($"Solving {problemSpec.id}...");
                        SolveWithProjectionSolverRunner(problemSpec);
                    });

                    Console.WriteLine("Waiting 1 minute...");
                    Thread.Sleep(TimeSpan.FromMinutes(1));
                }
            }
            else if (args.Contains("--convex"))
            {
                ShowIntro("ConvexPolygonSolver");
                var newProblems = DownloadNewProblems();
                ConvexPolygonSolver.SolveAll(newProblems);
                ConvexPolygonSolver.SolveAllNotSolvedPerfectly();
            }
            else
            {
                ShowIntro("DumbSolver");
                var newProblems = DownloadNewProblems();
                Console.Out.WriteLine($"newProblems.Count: {newProblems.Count}");
                var noSolutionProblems = repo.GetAllNotSolvedPerfectly().Where(x => repo.FindResponse(x.id) == null).Skip(15).ToList();
                Console.Out.WriteLine($"noSolutionProblems.Count: {noSolutionProblems.Count}");
                var sw = Stopwatch.StartNew();
                for (var i = 0; i < noSolutionProblems.Count; i++)
                {
                    var problem = noSolutionProblems[i];
                    Console.Write($"{sw.Elapsed:c} Problem {problem.id:0000} ({i:0000}/{noSolutionProblems.Count:0000}) ");
                    var solution = TryGetInitialSolution(problem);
                    if (solution != null)
                    {
                        ProblemsSender.Post(solution, problem.id);
                    }
                    Console.WriteLine();
                }
            }
        }
コード例 #2
0
        private static SolutionSpec TrySolve(ProblemSpec problem)
        {
            if (problem.Polygons.Length > 1 || !problem.Polygons.Single().IsConvex() || problem.Polygons.Single().GetSignedSquare() < 0)
            {
                return(null);
            }

            var problemPolygon = problem.Polygons[0];

            return(ConvexPolygonSolver.TrySolveInBestShot(problem, problemPolygon.GetConvexBoundary()));
        }