結果

問題 No.2738 CPC To F
ユーザー Lisp_CoderLisp_Coder
提出日時 2024-04-23 02:13:37
言語 Common Lisp
(sbcl 2.3.8)
結果
TLE  
実行時間 -
コード長 963 bytes
コンパイル時間 114 ms
コンパイル使用メモリ 33,376 KB
実行使用メモリ 131,908 KB
最終ジャッジ日時 2024-04-23 02:13:41
合計ジャッジ時間 3,834 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
27,392 KB
testcase_01 AC 9 ms
22,016 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 23 APR 2024 02:13:37 AM):

; file: /home/judge/data/code/Main.lisp
; in: DEFUN MAIN
;     (N (READ))
; 
; caught STYLE-WARNING:
;   The variable N is defined but never used.
; 
; compilation unit finished
;   caught 1 STYLE-WARNING condition


; wrote /home/judge/data/code/Main.fasl
; compilation finished in 0:00:00.023

ソースコード

diff #

(defun process-string (input-str)
  (let ((result-str "")
        (n (length input-str)))
    ;; パターンを置換
    (dotimes (i n)
      (setf result-str (concatenate 'string result-str (subseq input-str i (1+ i))))
      (when (and (>= (length result-str) 7)
                 (string= (subseq result-str (- (length result-str) 7) (length result-str)) "CPCTCPC"))
        (setf result-str (subseq result-str 0 (- (length result-str) 3)))
        (setf result-str (concatenate 'string result-str "F"))))
    result-str))

(defun count-cpctf (processed-str)
  (let ((count 0)
        (len (length processed-str)))
    (dotimes (i (- len 4))
      (when (string= (subseq processed-str i (+ i 5)) "CPCTF")
        (incf count)))
    count))

(defun main ()
  (let ((n (read))
        (input-str ""))
    (setf input-str (read-line))
    (let ((transformed-string (process-string input-str)))
      (format t "~A~%" (count-cpctf transformed-string)))))

(main)
0