結果
| 問題 |
No.2738 CPC To F
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-23 02:13:37 |
| 言語 | Common Lisp (sbcl 2.5.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 963 bytes |
| コンパイル時間 | 368 ms |
| コンパイル使用メモリ | 28,544 KB |
| 実行使用メモリ | 120,760 KB |
| 最終ジャッジ日時 | 2024-10-15 01:34:23 |
| 合計ジャッジ時間 | 4,129 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | TLE * 1 -- * 21 |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 15 OCT 2024 01:34:18 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.069
ソースコード
(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)