public object Solve() { var map = new Map(R, C); map.PlaceMines(M); map.Click(); return map.IsWon ? map.Render() : "Impossible"; }
static void Main(string[] args) { #if TEST_MAP_FILL for (int i = 0; i < 100; i++) { var map = new Map(10, 10); map.PlaceMines(i); Console.WriteLine(map.Render()); Console.WriteLine(); } return; #endif 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(); }