結果

問題 No.3 ビットすごろく
ユーザー 抹茶アイス抹茶アイス
提出日時 2023-07-24 17:32:13
言語 C#
(.NET 8.0.203)
結果
WA  
実行時間 -
コード長 795 bytes
コンパイル時間 9,481 ms
コンパイル使用メモリ 158,148 KB
実行使用メモリ 180,000 KB
最終ジャッジ日時 2024-04-08 21:41:48
合計ジャッジ時間 13,677 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
32,676 KB
testcase_01 AC 77 ms
32,676 KB
testcase_02 AC 78 ms
32,676 KB
testcase_03 AC 83 ms
32,804 KB
testcase_04 AC 82 ms
32,676 KB
testcase_05 AC 85 ms
33,060 KB
testcase_06 AC 80 ms
32,804 KB
testcase_07 AC 82 ms
32,804 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 80 ms
33,060 KB
testcase_13 AC 79 ms
32,804 KB
testcase_14 AC 83 ms
33,316 KB
testcase_15 AC 84 ms
33,444 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 79 ms
32,804 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 78 ms
32,676 KB
testcase_22 AC 81 ms
33,316 KB
testcase_23 AC 82 ms
33,444 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 77 ms
32,676 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 78 ms
32,676 KB
testcase_32 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (105 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
public class Program{
    public static void Main(){
        var n = int.Parse(Console.ReadLine());
        var a = new int[n];
        var b = new int[n];
        var c = new Queue<int>();
        for(var i=0;i<n;i++){
            a[i] = Convert.ToString(i+1,2).Count(m => m=='1');
            b[i] = -1;
        }
        c.Enqueue(0);
        b[0] = 1;
        while(c.Count>0){
            var k = c.Dequeue();
            if(k+a[k]<n&&b[k+a[k]]==-1){
                c.Enqueue(k+a[k]);
                b[k+a[k]] = b[k] + 1;
            }
            else if(k-a[k]>0&&b[k-a[k]]==-1){
                c.Enqueue(k-a[k]);
                b[k-a[k]] = b[k] + 1;
            }
        }
        Console.WriteLine(b[n-1]);
    }
}
0