結果

問題 No.588 空白と回文
ユーザー ducktailducktail
提出日時 2017-12-31 22:08:11
言語 Scheme
(Gauche-0.9.14)
結果
AC  
実行時間 171 ms / 2,000 ms
コード長 584 bytes
コンパイル時間 70 ms
コンパイル使用メモリ 5,372 KB
実行使用メモリ 11,972 KB
最終ジャッジ日時 2023-08-23 12:36:20
合計ジャッジ時間 3,027 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
11,844 KB
testcase_01 AC 18 ms
11,756 KB
testcase_02 AC 18 ms
11,692 KB
testcase_03 AC 171 ms
11,944 KB
testcase_04 AC 18 ms
11,688 KB
testcase_05 AC 17 ms
11,768 KB
testcase_06 AC 18 ms
11,676 KB
testcase_07 AC 18 ms
11,876 KB
testcase_08 AC 19 ms
11,844 KB
testcase_09 AC 19 ms
11,684 KB
testcase_10 AC 18 ms
11,760 KB
testcase_11 AC 169 ms
11,972 KB
testcase_12 AC 166 ms
11,712 KB
testcase_13 AC 18 ms
11,680 KB
testcase_14 AC 18 ms
11,676 KB
testcase_15 AC 18 ms
11,784 KB
testcase_16 AC 19 ms
11,952 KB
testcase_17 AC 115 ms
11,712 KB
testcase_18 AC 18 ms
11,756 KB
testcase_19 AC 18 ms
11,696 KB
testcase_20 AC 169 ms
11,712 KB
testcase_21 AC 140 ms
11,936 KB
testcase_22 AC 165 ms
11,732 KB
testcase_23 AC 105 ms
11,784 KB
testcase_24 AC 19 ms
11,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

(define (same-character s l r)
  (let loop ([c 0]
             [i l]
             [j (- r 1)])
    (cond [(= i r) c]
          [(char=? (string-ref s i) (string-ref s j)) (loop (+ c 1) (+ i 1) (- j 1))]
          [else (loop c (+ i 1) (- j 1))])))

(define (main args)
  (let* ([s (read-line)]
         [sl (string-length s)])
    (print
     (let loop ([l 0]
                [r 1]
                [mx 0])
       (cond [(= l sl) mx]
             [(= r sl) (loop (+ l 1) r (max mx (same-character s l r)))]
             [else (loop l (+ r 1) (max mx (same-character s l r)))]))))
  0)
0