Submission #1242770
Source Code Expand
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; namespace Codeforces { internal class Template { private void Solve() { var x = cin.NextLong(); var queue = new Queue<Tuple<int, int>>(); queue.Enqueue(Tuple.Create(0, 0)); while (queue.Any()) { var front = queue.Dequeue(); if (front.Item1 == x) { Console.WriteLine(front.Item2); return; } queue.Enqueue(Tuple.Create(front.Item1 - front.Item2 - 1, front.Item2 + 1)); queue.Enqueue(Tuple.Create(front.Item1, front.Item2 + 1)); queue.Enqueue(Tuple.Create(front.Item1 + front.Item2 + 1, front.Item2 + 1)); } } private static readonly Scanner cin = new Scanner(); private static void Main() { #if DEBUG var inputText = File.ReadAllText(@"..\..\input.txt"); var testCases = inputText.Split(new[] { "input" }, StringSplitOptions.RemoveEmptyEntries); var consoleOut = Console.Out; for (var i = 0; i < testCases.Length; i++) { var parts = testCases[i].Split(new[] { "output" }, StringSplitOptions.RemoveEmptyEntries); Console.SetIn(new StringReader(parts[0].Trim())); var stringWriter = new StringWriter(); Console.SetOut(stringWriter); var sw = Stopwatch.StartNew(); new Template().Solve(); sw.Stop(); var output = stringWriter.ToString(); Console.SetOut(consoleOut); var color = ConsoleColor.Green; var status = "Passed"; if (parts[1].Trim() != output.Trim()) { color = ConsoleColor.Red; status = "Failed"; } Console.ForegroundColor = color; Console.WriteLine("Test {0} {1} in {2}ms", i + 1, status, sw.ElapsedMilliseconds); } Console.ReadLine(); Console.ReadKey(); #else new Template().Solve(); Console.ReadLine(); #endif } } internal class Scanner { private string[] s = new string[0]; private int i; private readonly char[] cs = { ' ' }; public string NextString() { if (i < s.Length) return s[i++]; var line = Console.ReadLine() ?? string.Empty; s = line.Split(cs, StringSplitOptions.RemoveEmptyEntries); i = 1; return s.First(); } public double NextDouble() { return double.Parse(NextString()); } public int NextInt() { return int.Parse(NextString()); } public long NextLong() { return long.Parse(NextString()); } } }
Submission Info
Submission Time | |
---|---|
Task | C - Go Home |
User | Neverauskas |
Language | C# (Mono 4.6.2.0) |
Score | 0 |
Code Size | 2467 Byte |
Status | TLE |
Exec Time | 2131 ms |
Memory | 439460 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 200 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_000.txt, 0_001.txt, 0_002.txt |
All | 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_000.txt | AC | 25 ms | 11348 KB |
0_001.txt | AC | 24 ms | 9300 KB |
0_002.txt | AC | 25 ms | 11348 KB |
1_003.txt | TLE | 2130 ms | 435620 KB |
1_004.txt | TLE | 2130 ms | 435368 KB |
1_005.txt | AC | 24 ms | 9300 KB |
1_006.txt | TLE | 2130 ms | 434596 KB |
1_007.txt | TLE | 2130 ms | 434084 KB |
1_008.txt | TLE | 2130 ms | 437028 KB |
1_009.txt | TLE | 2130 ms | 435364 KB |
1_010.txt | TLE | 2130 ms | 433956 KB |
1_011.txt | TLE | 2130 ms | 434088 KB |
1_012.txt | TLE | 2131 ms | 437028 KB |
1_013.txt | TLE | 2130 ms | 437796 KB |
1_014.txt | TLE | 2130 ms | 438048 KB |
1_015.txt | TLE | 2130 ms | 438436 KB |
1_016.txt | TLE | 2130 ms | 436000 KB |
1_017.txt | TLE | 2126 ms | 439460 KB |