Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            ProblemParser.ParseProblem(@"D:\Chrome\Downloads\B-large.in");
            for (var problem = 0; problem < ProblemParser.Cases; problem++)
            {
                var input      = ProblemParser.GetNextLine().Split(' ');
                var offset     = 0;
                var c          = Int32.Parse(input[offset++]);
                var transmutes = new List <Transmute>();
                for (int i = 0; i < c; i++, offset++)
                {
                    transmutes.Add(new Transmute {
                        Element1 = input[offset][0], Element2 = input[offset][1], Result = input[offset][2]
                    });
                }

                var d             = Int32.Parse(input[offset++]);
                var opposingPairs = new List <OpposingPair>();
                for (int i = 0; i < d; i++, offset++)
                {
                    opposingPairs.Add(new OpposingPair {
                        Element1 = input[offset][0], Element2 = input[offset][1]
                    });
                }

                var toTransmute = input[offset + 1];
                ProblemParser.WriteSolution("[" + string.Join(", ", ApplyTransmutation(toTransmute, transmutes, opposingPairs).ToCharArray()) + "]");
            }
        }
Ejemplo n.º 2
0
        public static void Main(string[] args)
        {
            ProblemParser.ParseProblem(@"C:\Users\amissine\Downloads\A-large.in");
            for (var i = 0; i < ProblemParser.Cases; i++)
            {
                var input         = ProblemParser.GetNextLine();
                var inputs        = input.Split(' ');
                var numberOfSteps = Int32.Parse(inputs[0]);
                var steps         = new List <Step>();
                for (int j = 0; j < numberOfSteps; j++)
                {
                    var bot    = inputs[1 + j * 2][0];
                    var button = Int32.Parse(inputs[2 + j * 2]);
                    steps.Add(new Step {
                        Bot = bot, Button = button
                    });
                }

                var bLoc = 1;
                var oLoc = 1;
                var time = 0;
                for (int j = 0; j < numberOfSteps; j++)
                {
                    var step = steps[j];
                    if (step.Bot == 'B')
                    {
                        var timeTaken = Math.Abs(bLoc - step.Button) + 1;
                        time += timeTaken;
                        bLoc  = step.Button;
                        var nextOrangeStep = FindNextStep(j + 1, steps, 'O');
                        if (nextOrangeStep != null)
                        {
                            oLoc = MoveTowards(nextOrangeStep.Button, oLoc, timeTaken);
                        }
                    }
                    else
                    {
                        var timeTaken = Math.Abs(oLoc - step.Button) + 1;
                        time += timeTaken;
                        oLoc  = step.Button;
                        var nextBlueStep = FindNextStep(j + 1, steps, 'B');
                        if (nextBlueStep != null)
                        {
                            bLoc = MoveTowards(nextBlueStep.Button, bLoc, timeTaken);
                        }
                    }
                }

                ProblemParser.WriteSolution("" + time);
            }
        }