結果
問題 | No.3 ビットすごろく |
ユーザー | WagiHOH |
提出日時 | 2016-07-08 10:18:30 |
言語 | D (dmd 2.106.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 925 bytes |
コンパイル時間 | 666 ms |
コンパイル使用メモリ | 84,288 KB |
実行使用メモリ | 7,044 KB |
最終ジャッジ日時 | 2023-09-02 21:19:27 |
合計ジャッジ時間 | 2,416 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,372 KB |
testcase_01 | AC | 2 ms
4,368 KB |
testcase_02 | AC | 1 ms
4,372 KB |
testcase_03 | AC | 4 ms
6,648 KB |
testcase_04 | AC | 2 ms
4,368 KB |
testcase_05 | AC | 7 ms
6,940 KB |
testcase_06 | AC | 4 ms
6,976 KB |
testcase_07 | AC | 4 ms
6,444 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 7 ms
6,904 KB |
testcase_13 | AC | 4 ms
6,196 KB |
testcase_14 | AC | 9 ms
6,940 KB |
testcase_15 | AC | 12 ms
6,920 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 3 ms
6,456 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | AC | 1 ms
4,368 KB |
testcase_22 | AC | 10 ms
6,940 KB |
testcase_23 | AC | 12 ms
6,944 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 1 ms
4,368 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 1 ms
4,376 KB |
testcase_32 | WA | - |
ソースコード
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.range; import core.bitop; struct Block { uint bits; bool forward, backward; uint optimum = -1; } void main() { immutable n = readln.chomp.to!uint; auto game = new Block[n + 1]; foreach (i, ref x; game) x.bits = i.popcnt; uint[] route = [1]; while (!route.empty) { auto point = route.back; if (point < 1 || point > n) { route.popBack; continue; } with (game[point]) { optimum = min(route.length, optimum); if (!forward) { route ~= point + bits; forward = true; } else if (!backward) { route ~= point - bits; backward = true; } else { route.popBack; } } } writeln(cast(int)game[n].optimum); }