示例#1
0
        static void Main()
        {
            var records = new List <long>();

            while (true)
            {
                try
                {
                    using (var sc = new SetConsole())
                    {
                        var sw = new Stopwatch();
                        sw.Start();
                        Program.Main(null);
                        sw.Stop();
                        records.Add(sw.ElapsedMilliseconds);
                        sw.Reset();
                    }
                    var s = new StreamWriter(Console.OpenStandardOutput())
                    {
                        AutoFlush = true
                    };
                    Console.SetOut(s);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    Console.WriteLine("Process was supended");
                    break;
                }
                if (records.Any())
                {
                    Console.WriteLine($"AveTime is {records.Average()}ms");
                }
            }
        }
示例#2
0
        public static void Main(string[] args)
        {
            using (var sc = new SetConsole())
            {
                var           nm          = GetArrayIntInput();
                List <City>[] Prefectures = new List <City> [nm[0] + 1];
                for (int i = 1; i <= nm[0]; i++)
                {
                    Prefectures[i] = new List <City>();
                }
                for (int i = 1; i <= nm[1]; i++)
                {
                    var py = GetArrayIntInput();
                    Prefectures[py[0]].Add(new City(i, py[1]));
                }

                var results = new List <City>();
                for (int i = 1; i <= nm[0]; i++)
                {
                    Prefectures[i] = Prefectures[i].OrderBy(p => p.Id).ToList();
                    for (int j = 0; j < Prefectures[i].Count; j++)
                    {
                        Prefectures[i][j].Id = (long)i * 1000000 + j + 1;
                        results.Add(Prefectures[i][j]);
                    }
                }

                foreach (var id in results.OrderBy(r => r.Order).Select(r => r.Id))
                {
                    CWrite(Convert.ToString(id, 10).PadLeft(12, '0'));
                }
            }
        }