結果
問題 | No.225 文字列変更(medium) |
ユーザー |
![]() |
提出日時 | 2024-11-06 10:14:02 |
言語 | Common Lisp (sbcl 2.5.0) |
結果 |
AC
|
実行時間 | 39 ms / 5,000 ms |
コード長 | 739 bytes |
コンパイル時間 | 154 ms |
コンパイル使用メモリ | 43,708 KB |
実行使用メモリ | 46,716 KB |
最終ジャッジ日時 | 2024-11-06 10:14:04 |
合計ジャッジ時間 | 1,774 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 06 NOV 2024 10:14:01 AM): ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.024
ソースコード
(defun LevenshteinDistance (s1 s2)(let ((dp (make-array '(2048 2048)))(n (length s1))(m (length s2)))(dotimes (i (1+ n)) (setf (aref dp i 0) i))(dotimes (i (1+ m)) (setf (aref dp 0 i) i))(dotimes (i n)(dotimes (j m)(setf (aref dp (1+ i) (1+ j)) (1+ (min (aref dp i (1+ j)) (aref dp (1+ i) j)))(aref dp (1+ i) (1+ j)) (min (aref dp (1+ i) (1+ j)) (+ (aref dp i j) (if (char= (char s1 i) (char s2 j)) 0 1))))))(aref dp n m)))(defun main (&rest argv)(declare (ignorable argv))(let* ((n (read))(m (read))(s1 (read-line))(s2 (read-line)))(declare (ignore n) (ignore m))(format t "~d~%" (LevenshteinDistance s1 s2))))(main)