Пример #1
0
        public static List <Aula> Get_Aulas()
        {
            var aulas = new List <Aula>();

            using (_fileManager)
            {
                _fileManager.OpenFile(_dirAulas, false, false);
                while (_fileManager.Readable)
                {
                    var datos = _fileManager.ReadLine().Split(',');
                    aulas.Add(new Aula(datos[0],
                                       Convert.ToInt32(datos[1])));
                }
            }
            return(aulas);
        }
Пример #2
0
        static void Magic_Trick()
        {
            int T = File_Manager.ReadInts()[0];

            for (int t = 0; t < T; t++)
            {
                int        ans1 = File_Manager.ReadInts()[0];
                List <int> row1 = new List <int>();
                for (int r = 1; r < 5; r++)
                {
                    if (r == ans1)
                    {
                        row1 = File_Manager.ReadInts();
                    }
                    else
                    {
                        File_Manager.ReadLine();
                    }
                }

                int        ans2 = File_Manager.ReadInts()[0];
                List <int> row2 = new List <int>();
                for (int r = 1; r < 5; r++)
                {
                    if (r == ans2)
                    {
                        row2 = File_Manager.ReadInts();
                    }
                    else
                    {
                        File_Manager.ReadLine();
                    }
                }

                List <int> values = new List <int>();
                foreach (int a in row1)
                {
                    if (row2.Contains(a))
                    {
                        values.Add(a);
                    }
                }
                if (values.Count == 0)
                {
                    File_Manager.QueueLine("Case #" + (t + 1).ToString() + ": " + "Volunteer cheated!");
                }
                else if (values.Count == 1)
                {
                    File_Manager.QueueLine("Case #" + (t + 1).ToString() + ": " + values[0]);
                }
                else
                {
                    File_Manager.QueueLine("Case #" + (t + 1).ToString() + ": " + "Bad magician!");
                }
            }
        }
Пример #3
0
        static void The_Repeater()
        {
            int T = File_Manager.ReadInts()[0];

            for (int t = 0; t < T; t++)
            {
                bool         fail    = false;
                int          N       = File_Manager.ReadInts()[0];
                string[]     strings = new string[N];
                List <char>  order   = new List <char>();
                List <int[]> counts  = new List <int[]>();
                for (int n = 0; n < N; n++)
                {
                    strings[n] = File_Manager.ReadLine();
                    char[] letters = strings[n].ToCharArray();
                    if (n == 0)
                    {
                        order.Add(letters[0]);
                        counts.Add(new int[N]);
                    }
                    int orderNo = 0;
                    for (int i = 0; i < letters.Length; i++)
                    {
                        if (letters[i] == order[orderNo])
                        {
                            counts[orderNo][n]++;
                        }
                        else
                        {
                            if (order.Count > orderNo + 1)
                            {
                                if (order[orderNo + 1] == letters[i])
                                {
                                    orderNo++;
                                    counts[orderNo][n] = 1;
                                }
                                else
                                {
                                    fail = true;
                                }
                            }
                            else
                            {
                                orderNo++;
                                order.Add(letters[i]);
                                counts.Add(new int[N]);
                                counts[orderNo][n] = 1;
                            }
                        }
                    }
                }
                int noChars = order.Count;
                int moves   = 0;
                for (int i = 0; i < noChars; i++)
                {
                    if (counts[i].Contains(0))
                    {
                        fail = true;
                    }
                    else
                    {
                        Array.Sort(counts[i]);
                        for (int a = 0; a < N; a++)
                        {
                            moves += Math.Abs(counts[i][a] - counts[i][(int)(N / 2)]);
                        }
                    }
                }
                if (fail)
                {
                    File_Manager.QueueLine("Case #" + (t + 1).ToString() + ": " + "Fegla Won");
                }
                else
                {
                    File_Manager.QueueLine("Case #" + (t + 1).ToString() + ": " + moves);
                }
            }
        }