Esempio n. 1
0
 public static void Main(string[] args)
 {
     using (var sc = new SetConsole())
     {
         int n        = GetIntInput();
         var xyhs     = new List <int[]>();
         var zerolist = new List <int[]>();
         for (int i = 0; i < n; i++)
         {
             var tmp = Console.ReadLine().Split().Select(int.Parse).ToArray();
             if (tmp[2] == 0)
             {
                 zerolist.Add(tmp);
                 continue;
             }
             xyhs.Add(tmp);
         }
         var  a      = xyhs.Concat(zerolist).ToList();
         bool result = false;
         for (int i = 0; i <= 100; i++)
         {
             for (int j = 0; j <= 100; j++)
             {
                 int expH = Math.Abs(xyhs[0][0] - i) + Math.Abs(xyhs[0][1] - j) + xyhs[0][2];
                 var flg  = true;
                 for (int k = 0; k < a.Count; k++)
                 {
                     if (a[k][2] != Math.Max(expH - Math.Abs(a[k][0] - i) - Math.Abs(a[k][1] - j), 0))
                     {
                         flg = false;
                         break;
                     }
                 }
                 if (flg && expH >= 1)
                 {
                     Console.WriteLine($"{i} {j} {expH}"); result = true; break;
                 }
             }
             if (result)
             {
                 break;
             }
         }
     }
 }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            using (var sc = new SetConsole())
            {
                int n    = GetIntInput();
                var xyh  = new int[3];
                var list = new List <int[]>();
                for (int i = 0; i < n; i++)
                {
                    var tmp = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    if (tmp[2] != 0)
                    {
                        xyh = tmp;
                    }
                    list.Add(tmp);
                }

                bool result = false;
                for (int i = 0; i <= 100; i++)
                {
                    for (int j = 0; j <= 100; j++)
                    {
                        int expH = Math.Abs(xyh[0] - i) + Math.Abs(xyh[1] - j) + xyh[2];
                        var flg  = true;
                        for (int k = 0; k < list.Count; k++)
                        {
                            if (list[k][2] != Math.Max(expH - Math.Abs(list[k][0] - i) - Math.Abs(list[k][1] - j), 0))
                            {
                                flg = false;
                                break;
                            }
                        }
                        if (flg && expH >= 1)
                        {
                            Console.WriteLine($"{i} {j} {expH}"); result = true; break;
                        }
                    }
                    if (result)
                    {
                        break;
                    }
                }
            }
        }
Esempio n. 3
0
        static void Main()
        {
            var records = new List <long>();

            while (true)
            {
                try
                {
                    using (var sc = new SetConsole())
                    {
                        var sw = new Stopwatch();
                        sw.Start();
                        Program.Main2(null);
                        sw.Stop();
                        records.Add(sw.ElapsedMilliseconds);
                        sw.Reset();
                    }
                }
                catch (Exception ex)
                {
                    var s = new StreamWriter(Console.OpenStandardOutput())
                    {
                        AutoFlush = true
                    };
                    Console.SetOut(s);
                    Console.WriteLine(ex.ToString());
                    Console.WriteLine("Process was supended");
                    Console.ReadLine();
                    break;
                }
                if (records.Any())
                {
                    Console.WriteLine($"AveTime is {records.Average()}ms");
                }
            }
        }