結果

問題 No.566 だいたい完全二分木
ユーザー ducktailducktail
提出日時 2018-01-01 14:31:49
言語 Scheme
(Gauche-0.9.14)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 474 bytes
コンパイル時間 341 ms
コンパイル使用メモリ 5,336 KB
実行使用メモリ 13,848 KB
最終ジャッジ日時 2023-08-24 15:21:16
合計ジャッジ時間 2,292 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
11,644 KB
testcase_01 AC 17 ms
11,612 KB
testcase_02 AC 17 ms
11,724 KB
testcase_03 AC 17 ms
11,852 KB
testcase_04 AC 17 ms
11,680 KB
testcase_05 AC 18 ms
11,708 KB
testcase_06 AC 17 ms
11,888 KB
testcase_07 AC 18 ms
11,856 KB
testcase_08 AC 18 ms
12,488 KB
testcase_09 AC 25 ms
12,816 KB
testcase_10 AC 44 ms
13,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

(define (cb-tree l r)
  (reverse
   (let helper ([l l]
                [r r]
                [ls '()])
     (let ([m (quotient (+ l r) 2)])
       (cond [(= l r) (cons m ls)]
             [else (helper (+ m 1) r (helper l (- m 1) (cons m ls)))])))))

(define (main args)
  (let ([k (read)])
    (print
     (let* ([cbt (cb-tree 1 (- (expt 2 k) 1))]
            [pcbt (cons (cadr cbt) (cons (car cbt) (cddr cbt)))])
       (string-join (map number->string pcbt) " "))))
  0)
0