結果

問題 No.392 2分木をたどれ
ユーザー むらためむらため
提出日時 2019-01-21 12:02:03
言語 Nim
(2.0.2)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 554 bytes
コンパイル時間 2,810 ms
コンパイル使用メモリ 108,216 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 02:26:43
合計ジャッジ時間 3,256 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 7 ms
4,376 KB
testcase_02 AC 7 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sequtils
template times*(n:int,body) = (for _ in 0..<n: body)
proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .}
proc scan(): int =
  while true:
    let k = getchar_unlocked()
    if k < '0': break
    result = 10 * result + k.ord - '0'.ord

proc path(n:int) : string =
  if n == 0 : return "??"
  if n == 1 : return "L"
  if n == 2 : return "R"
  if n mod 2 == 1: return path(n div 2) & "L"
  return path((n-1) div 2) & "R"

const pathes = toSeq(0..4096).mapIt(it.path)
let m = scan()
m.times: echo pathes[scan()]
0