本文整理汇总了C#中Solution.solve方法的典型用法代码示例。如果您正苦于以下问题:C# Solution.solve方法的具体用法?C# Solution.solve怎么用?C# Solution.solve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Solution
的用法示例。
在下文中一共展示了Solution.solve方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main(string[] args)
{
Solution solution = new Solution();
using (System.IO.TextReader input =
CaideConstants.InputFile == null ? System.Console.In :
new System.IO.StreamReader(CaideConstants.InputFile))
using (System.IO.TextWriter output =
CaideConstants.OutputFile == null ? System.Console.Out:
new System.IO.StreamWriter(CaideConstants.OutputFile))
solution.solve(input, output);
}
示例2: Main
public static void Main(string[] args)
{
// Read path to caide executable from a file in current directory
string testDir = ".";
string caideExeFile = Path.Combine(testDir, "caideExe.txt");
if (!File.Exists(caideExeFile))
{
testDir = Path.Combine(".caideproblem", "test");
caideExeFile = Path.Combine(testDir, "caideExe.txt");
}
if (!File.Exists(caideExeFile))
{
throw new InvalidOperationException("Test must be run from either problem directory or .caideproblem/test subdirectory");
}
string caideExe = File.ReadAllText(caideExeFile).Trim();
// Prepare the list of test cases in correct order; add recently created test cases too.
Process updateTestsProcess = Run(caideExe, "update_tests");
updateTestsProcess.WaitForExit();
if (updateTestsProcess.ExitCode != 0)
{
Console.Error.WriteLine("caide update_tests returned non-zero error code " + updateTestsProcess.ExitCode);
}
// Process each test case described in a file in current directory
foreach (string line in File.ReadAllLines(Path.Combine(testDir, "testList.txt")))
{
string[] words = line.Split(' ');
string testName = words[0], testState = words[1];
if (testState == "Skip")
{
Console.Error.WriteLine("Skipping test " + testName);
// mark test as skipped
File.WriteAllText(Path.Combine(testDir, testName + ".skipped"), "");
}
else if (testState == "Run")
{
Console.Error.WriteLine("Running test " + testName);
TextWriter output = new StringWriter();
using (TextReader input = new StreamReader(Path.Combine(testDir, testName + ".in")))
{
try
{
Solution solution = new Solution();
solution.solve(input, output);
}
catch
{
Console.Error.WriteLine("Test " + testName + " threw an exception");
// mark test as failed
File.WriteAllText(Path.Combine(testDir, testName + ".failed"), "");
}
}
// save program output
string result = output.ToString();
File.WriteAllText(Path.Combine(testDir, testName + ".out"), result);
// optional: print program output to stderr
if (result.Length > 100)
result = result.Substring(0, 100) + "[...] (output truncated)\n";
Console.Error.WriteLine(result);
}
else
{
// internal caide error: unknown test status
File.WriteAllText(Path.Combine(testDir, testName + ".error"), "");
}
}
// optional: evaluate tests automatically
Process evalTestsProcess = Run(caideExe, "eval_tests");
evalTestsProcess.WaitForExit();
if (evalTestsProcess.ExitCode != 0)
{
Console.Error.WriteLine("Tests failed (exit code: " + evalTestsProcess.ExitCode + " )");
Environment.Exit(evalTestsProcess.ExitCode);
}
}
示例3: Main
public static void Main(string[] args)
{
Solution solution = new Solution();
solution.solve(System.Console.In, System.Console.Out);
}