結果
問題 | No.3 ビットすごろく |
ユーザー | masakt |
提出日時 | 2017-03-26 20:23:12 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,368 bytes |
コンパイル時間 | 2,104 ms |
コンパイル使用メモリ | 103,916 KB |
実行使用メモリ | 23,732 KB |
最終ジャッジ日時 | 2023-09-20 11:06:46 |
合計ジャッジ時間 | 5,464 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 61 ms
23,628 KB |
testcase_01 | AC | 61 ms
21,484 KB |
testcase_02 | AC | 61 ms
21,432 KB |
testcase_03 | AC | 62 ms
21,636 KB |
testcase_04 | WA | - |
testcase_05 | AC | 64 ms
23,552 KB |
testcase_06 | AC | 64 ms
23,544 KB |
testcase_07 | AC | 62 ms
21,440 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 64 ms
21,600 KB |
testcase_13 | AC | 62 ms
23,632 KB |
testcase_14 | AC | 67 ms
21,620 KB |
testcase_15 | AC | 67 ms
23,508 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 62 ms
21,580 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | AC | 60 ms
21,400 KB |
testcase_22 | AC | 66 ms
23,644 KB |
testcase_23 | AC | 68 ms
21,628 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 59 ms
23,544 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
コンパイルメッセージ
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 P { static int Search(int goal) { int x = path.Last(); int step = Convert.ToString(x, 2).Replace("0", "").Length; int post = x + step; int pre = x - step; int count = 0; path.Add(post); if (x == goal) { return 1; } while (path.Count != 0 && count != path.Count) { if (x == goal) { return path.Count + 1; } else { x = path.Last(); step = Convert.ToString(x, 2).Replace("0", "").Length; post = x + step; pre = x - step; if (!path.Contains(post) && 1 <= post && post <= goal) { path.Add(post); } else if (!path.Contains(pre) && 1 <= pre && pre <= goal) { path.Add(pre); } else { count = path.Count; path.Remove(x); } } } return -1; } static List<int> path = new List<int>() { 1 }; static void Main() { Console.WriteLine(Search(int.Parse(Console.ReadLine()))); } }