結果
問題 | No.240 ナイト散歩 |
ユーザー | 明智重蔵 |
提出日時 | 2015-09-12 10:23:45 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,831 bytes |
コンパイル時間 | 2,558 ms |
コンパイル使用メモリ | 106,168 KB |
実行使用メモリ | 25,012 KB |
最終ジャッジ日時 | 2023-09-26 11:36:24 |
合計ジャッジ時間 | 6,747 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 70 ms
24,960 KB |
testcase_01 | AC | 70 ms
22,680 KB |
testcase_02 | WA | - |
testcase_03 | AC | 71 ms
24,740 KB |
testcase_04 | AC | 70 ms
24,728 KB |
testcase_05 | AC | 71 ms
24,920 KB |
testcase_06 | AC | 71 ms
24,916 KB |
testcase_07 | AC | 71 ms
22,856 KB |
testcase_08 | AC | 71 ms
22,916 KB |
testcase_09 | AC | 70 ms
22,756 KB |
testcase_10 | AC | 71 ms
22,956 KB |
testcase_11 | AC | 71 ms
24,808 KB |
testcase_12 | AC | 70 ms
22,860 KB |
testcase_13 | AC | 71 ms
22,884 KB |
testcase_14 | AC | 70 ms
22,964 KB |
testcase_15 | AC | 71 ms
22,912 KB |
testcase_16 | AC | 72 ms
22,748 KB |
testcase_17 | AC | 71 ms
22,972 KB |
testcase_18 | AC | 70 ms
24,904 KB |
testcase_19 | AC | 70 ms
24,996 KB |
testcase_20 | AC | 71 ms
22,856 KB |
testcase_21 | AC | 72 ms
22,768 KB |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | AC | 70 ms
24,924 KB |
testcase_25 | AC | 71 ms
22,956 KB |
testcase_26 | AC | 70 ms
22,908 KB |
testcase_27 | AC | 71 ms
24,884 KB |
testcase_28 | AC | 70 ms
24,976 KB |
testcase_29 | AC | 70 ms
22,760 KB |
testcase_30 | AC | 69 ms
22,852 KB |
testcase_31 | AC | 71 ms
22,908 KB |
testcase_32 | AC | 70 ms
24,804 KB |
testcase_33 | AC | 70 ms
22,896 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.Linq; class Program { static string InputPattern = "Input5"; static List<string> GetInputList() { var WillReturn = new List<string>(); if (InputPattern == "Input1") { WillReturn.Add("1 2"); //YES //1歩で移動可能である。 } else if (InputPattern == "Input2") { WillReturn.Add("5 -4"); //YES //ちょうど3歩で移動できる。 } else if (InputPattern == "Input3") { WillReturn.Add("100 100"); //NO //3歩以内ではたどり着けない。 } else if (InputPattern == "Input4") { WillReturn.Add("0 0"); //YES //1歩も動かないで辿りつける。 } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } struct JyoutaiDef { internal int Level; internal int CurrX; internal int CurrY; } static void Main() { List<string> InputList = GetInputList(); int[] wkArr = InputList[0].Split(' ').Select(A => int.Parse(A)).ToArray(); int X = wkArr[0]; int Y = wkArr[1]; var VisitedSet = new HashSet<string>(); var stk = new Stack<JyoutaiDef>(); JyoutaiDef WillPush; WillPush.Level = 0; WillPush.CurrX = WillPush.CurrY = 0; stk.Push(WillPush); VisitedSet.Add(string.Format("({0},{1})", 0, 0)); while (stk.Count > 0) { JyoutaiDef Popped = stk.Pop(); //クリア処理 if (Popped.Level == 3) continue; Action<int, int> PushSyori = (pNewX, pNewY) => { //再訪不可 string wkStr = string.Format("({0},{1})", pNewX, pNewY); if (VisitedSet.Add(wkStr) == false) return; WillPush.Level = Popped.Level + 1; WillPush.CurrX = pNewX; WillPush.CurrY = pNewY; stk.Push(WillPush); }; PushSyori(Popped.CurrX - 2, Popped.CurrY - 1); PushSyori(Popped.CurrX - 2, Popped.CurrY + 1); PushSyori(Popped.CurrX - 1, Popped.CurrY - 2); PushSyori(Popped.CurrX - 1, Popped.CurrY + 2); PushSyori(Popped.CurrX + 1, Popped.CurrY - 2); PushSyori(Popped.CurrX + 1, Popped.CurrY + 2); PushSyori(Popped.CurrX + 2, Popped.CurrY - 1); PushSyori(Popped.CurrX + 2, Popped.CurrY - 1); } bool CanVisit = VisitedSet.Contains(string.Format("({0},{1})", X, Y)); Console.WriteLine(CanVisit ? "YES" : "NO"); } }