static void Main(string[] args) { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; foreach (var inputFileName in Directory.EnumerateFiles(".", "*.in")) { var outputFileName = Path.ChangeExtension(inputFileName, ".out"); Console.WriteLine("Solving {0}...", inputFileName); var inputFile = new InputFile(inputFileName); using (var outputFile = new OutputFile(outputFileName)) { foreach (var testCase in inputFile.TestCases) { var chrono = new Stopwatch(); chrono.Start(); outputFile.Add(testCase.Solve()); chrono.Stop(); if( chrono.ElapsedMilliseconds > 1000 ) Console.WriteLine(" -> {0}", chrono.Elapsed); } } Console.WriteLine("Solving {0}... done", inputFileName); } Console.WriteLine("-- PRESS ENTER TO CLOSE --"); Console.ReadLine(); }
static void Main(string[] args) { foreach( var inputFileName in Directory.EnumerateFiles(".", "*.in") ) { var outputFileName = Path.ChangeExtension(inputFileName, ".out"); Console.WriteLine("Solving {0}...", inputFileName); var inputFile = new InputFile(inputFileName); using( var outputFile = new OutputFile(outputFileName)) { foreach (var testCase in inputFile) { Console.WriteLine("TestCase: {0}", testCase); var sortedX = new Vector(testCase.X.OrderBy(xi => xi)); var sortedY = new Vector(testCase.Y.OrderByDescending(yi => yi)); var product = sortedX * sortedY; var testResult = new TestResult(product); Console.WriteLine("TestResult: {0}", testResult); outputFile.Add(testResult); } } Console.WriteLine("Solving {0}... done", inputFileName); } Console.WriteLine("-- PRESS ENTER TO CLOSE --"); Console.ReadLine(); }
static void Main(string[] args) { foreach( var inputFileName in System.IO.Directory.EnumerateFiles(".", "*.in") ) { var outputFileName = Path.ChangeExtension(inputFileName, ".out"); Console.WriteLine("Solving {0}...", inputFileName); var inputFile = new InputFile(inputFileName); using( var outputFile = new OutputFile(outputFileName)) { foreach (var testCase in inputFile.TestCases) { Console.WriteLine("TestCase: {0}", testCase); var mkdirCount = 0; var root = new Directory(); foreach (var directory in testCase.ExistingDirectories) { Debug.Assert(!string.IsNullOrEmpty(directory)); Debug.Assert(directory[0] == '/'); root.Mkdir(directory.Substring(1)); } foreach (var directory in testCase.DirectoriesToCreate) { Debug.Assert(!string.IsNullOrEmpty(directory)); Debug.Assert(directory[0] == '/'); mkdirCount += root.Mkdir(directory.Substring(1)); } var testResult = new TestResult(mkdirCount); Console.WriteLine("TestResult: {0}", testResult); outputFile.Add(testResult); } } Console.WriteLine("Solving {0}... done", inputFileName); } Console.WriteLine("-- PRESS ENTER TO CLOSE --"); Console.ReadLine(); }
static void Main(string[] args) { foreach( var inputFileName in Directory.EnumerateFiles(".", "*.in") ) { var outputFileName = Path.ChangeExtension(inputFileName, ".out"); Console.WriteLine("Solving {0}...", inputFileName); var inputFile = new InputFile(inputFileName); using( var outputFile = new OutputFile(outputFileName)) { foreach (var testCase in inputFile.TestCases) { Console.WriteLine("TestCase: {0}", testCase); var intersectionCount = 0; for (int index1 = 0; index1 < testCase.Wires.Count-1; index1++) { var wire1 = testCase.Wires[index1]; for (int index2 = index1+1; index2 < testCase.Wires.Count; index2++) { var wire2 = testCase.Wires[index2]; if (wire1.Intersects(wire2)) intersectionCount++; } } var testResult = new TestResult(intersectionCount); Console.WriteLine("TestResult: {0}", testResult); outputFile.Add(testResult); } } Console.WriteLine("Solving {0}... done", inputFileName); } Console.WriteLine("-- PRESS ENTER TO CLOSE --"); Console.ReadLine(); }
static void Main(string[] args) { foreach( var inputFileName in Directory.EnumerateFiles(".", "*.in") ) { var outputFileName = Path.ChangeExtension(inputFileName, ".out"); Console.WriteLine("Solving {0}...", inputFileName); var inputFile = new InputFile(inputFileName); using( var outputFile = new OutputFile(outputFileName)) { foreach (var testCase in inputFile.TestCases) { Console.WriteLine("TestCase: {0}", testCase); var pattern = testCase.Pattern; pattern = pattern.Replace('(','['); pattern = pattern.Replace(')',']'); var regex = new Regex(pattern, RegexOptions.Compiled); var matchCount = inputFile.Dictionnary.Count(regex.IsMatch); var testResult = new TestResult(matchCount); Console.WriteLine("TestResult: {0}", testResult); outputFile.Add(testResult); } } Console.WriteLine("Solving {0}... done", inputFileName); } Console.WriteLine("-- PRESS ENTER TO CLOSE --"); Console.ReadLine(); }