Exemple #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()) + "]");
            }
        }
Exemple #2
0
 public static void Main(string[] args)
 {
     ProblemParser.ParseProblem(@"D:\Chrome\Downloads\D-large.in");
     for (var problem = 0; problem < ProblemParser.Cases; problem++)
     {
         var input = ProblemParser.GetLines(2);
         var array = new List <string>(input[1].Split(' ')).Select(Int64.Parse).ToList();
         var copy  = new List <string>(input[1].Split(' ')).Select(Int64.Parse).ToList();
         copy.Sort();
         ProblemParser.WriteSolution(array.Where((t, i) => t != copy[i]).Count() + ".000000");
     }
 }
Exemple #3
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);
            }
        }
Exemple #4
0
        public static void Main(string[] args)
        {
            ProblemParser.ParseProblem(@"D:\Chrome\Downloads\C-large.in");
            for (var problem = 0; problem < ProblemParser.Cases; problem++)
            {
                var input   = ProblemParser.GetLines(2);
                var candies = new List <string>(input[1].Split(' ')).Select(Int64.Parse).ToList();
                candies.Sort();

                var bits = new int[30];
                foreach (var candy in candies)
                {
                    CountBits(bits, candy);
                }
                if (!bits.All(bit => bit % 2 == 0))
                {
                    ProblemParser.WriteSolution("NO");
                }
                else
                {
                    ProblemParser.WriteSolution("" + (candies.Sum() - candies.First()));
                }
            }
        }