結果
問題 | No.3 ビットすごろく |
ユーザー |
![]() |
提出日時 | 2023-08-03 11:10:17 |
言語 | Nim (2.2.0) |
結果 |
AC
|
実行時間 | 4 ms / 5,000 ms |
コード長 | 411 bytes |
コンパイル時間 | 4,515 ms |
コンパイル使用メモリ | 66,304 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 07:55:00 |
合計ジャッジ時間 | 5,698 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 33 |
ソースコード
import deques, sequtils, strutilslet n = parseInt readLine stdinlet cnts = (0 .. n).mapIt toBin(it, 16).count '1'var dist = repeat(-1, succ n)dist[1] = 1var q = toDeque [1]while q.len > 0:var i = popFirst qlet i2 = [i.pred cnts[i], i.succ cnts[i]]for next in i2:if next > 1 and next < n.succ:if dist[next] == -1:dist[next] = dist[i] + 1q.addLast nextecho dist[n]