結果
| 問題 |
No.24 数当てゲーム
|
| コンテスト | |
| ユーザー |
Common Lisp
|
| 提出日時 | 2024-10-06 03:26:41 |
| 言語 | Common Lisp (sbcl 2.5.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 5,000 ms |
| コード長 | 1,365 bytes |
| コンパイル時間 | 434 ms |
| コンパイル使用メモリ | 39,304 KB |
| 実行使用メモリ | 29,888 KB |
| 最終ジャッジ日時 | 2024-10-06 03:26:42 |
| 合計ジャッジ時間 | 971 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 06 OCT 2024 03:26:40 AM): ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.137
ソースコード
; YESであってもNOのときと同じ処理を行う
; つまりYES以外の数はNOである
; 10個の0を要素に持つ配列を用意し
; NOであるときの数を1つ増やす
; 最後まで0であるものを出力する
(defun main ()
(let* ((n (read))
(s (make-array 10 :initial-element 0)))
; dotimes は指定した回数だけ反復処理を行うための構文
(dotimes (i n)
(let* ((a (read))
(b (read))
(c (read))
(d (read))
(e (read)))
(if (eq 'YES e)
; progn は複数の処理をまとめて順番に実行できる
(progn
; map-into を使うことで破壊的な変更を行える
(map-into s (lambda (x) (1+ x)) s)
(setf (aref s a) (1- (aref s a)))
(setf (aref s b) (1- (aref s b)))
(setf (aref s c) (1- (aref s c)))
(setf (aref s d) (1- (aref s d))))
(progn
(setf (aref s a) (1+ (aref s a)))
(setf (aref s b) (1+ (aref s b)))
(setf (aref s c) (1+ (aref s c)))
(setf (aref s d) (1+ (aref s d)))))))
(princ
; position item sequence &key from-end test test-not start end key
; sequence内にあるitemの順序を求める
(position 0 s))
(terpri)))
(main)
Common Lisp