static void Main(string[] args) { GraphPanel graph = new GraphPanel(); tests new_test = new tests(); StreamReader input_stream = new StreamReader("input.txt"); StreamWriter output_stream = new StreamWriter("output.txt"); Stopwatch stopWatch = new Stopwatch(); graph.Activate(); graph.Show(); graph.createGraph(); int N = Int32.Parse(input_stream.ReadLine()); int[,] dots = new int[N, 2]; for (int i = 0; i < N; i++) { string[] input = input_stream.ReadLine().Split(' '); dots[i, 0] = Int32.Parse(input[0]); dots[i, 1] = Int32.Parse(input[1]); graph.putDot(dots[i, 0], dots[i, 1]); } input_stream.Close(); stopWatch.Start(); //Сортируем точки по оси X в порядке возрастания QuickSort(dots, 0, N - 1, 0); int index_max = 0, index_min = 0, curr_max = dots[0, 1], curr_min = dots[0, 1], index = 1; //Опредеяем стартовые точки для начала обрисовки границ. Это максимальный и минимальный элемент по Y с самым меньшим X while (index < N && dots[index, 0] == dots[index - 1, 0]) { if (dots[index, 1] < curr_min) { curr_min = dots[index, 1]; index_min = index; } if (dots[index, 1] > curr_max) { curr_max = dots[index, 1]; index_max = index; } index++; } output_stream.WriteLine(Math.Round(UpperBorder(dots, N, graph, index_max) + LowerBorder(dots, N, graph, index_min) + VerticalLine(dots[index_max, 0], curr_max, curr_min, graph), 2)); stopWatch.Stop(); output_stream.WriteLine(stopWatch.Elapsed); output_stream.Close(); Console.ReadKey(); }
static void Main(string[] args) { tests tests = new tests(); StreamReader input_stream = new StreamReader("input.txt"); StreamWriter output_stream = new StreamWriter("output.txt"); Stopwatch stopWatch = new Stopwatch(); string first, second; while (!input_stream.EndOfStream) { first = input_stream.ReadLine(); second = input_stream.ReadLine(); stopWatch.Restart(); output_stream.WriteLine(findMaxSubstring(first, second)); output_stream.WriteLine(stopWatch.Elapsed); } output_stream.Close(); input_stream.Close(); }
static void Main(string[] args) { tests new_tests = new tests(); StreamReader input_stream = new StreamReader("input.txt"); StreamWriter output_stream = new StreamWriter("output.txt"); Stopwatch stopWatch = new Stopwatch(); string[] input; short N, M; HashSet <HashSet <int> > sets; while (!input_stream.EndOfStream) { double starting_memory = Process.GetCurrentProcess().WorkingSet64 / 1024; input = input_stream.ReadLine().Split(' '); N = Int16.Parse(input[0]); M = Int16.Parse(input[1]); sets = new HashSet <HashSet <int> >(); for (int i = 0; i < N; i++) { input = input_stream.ReadLine().Split(' '); sets.Add(new HashSet <int>()); for (int j = 0; j < M; j++) { sets.ElementAt(i).Add(Int32.Parse(input[j])); } } Console.WriteLine("GOTOVA"); stopWatch.Restart(); output_stream.WriteLine(anotherIntersections(sets, N)); output_stream.WriteLine("Estimated time: " + stopWatch.Elapsed); output_stream.WriteLine("Estimated memory: " + (Process.GetCurrentProcess().WorkingSet64 / 1024 - starting_memory) + " KB"); } input_stream.Close(); output_stream.Close(); }