結果
| 問題 | No.239 にゃんぱすー |
| コンテスト | |
| ユーザー |
Common Lisp
|
| 提出日時 | 2024-10-08 17:51:07 |
| 言語 | Common Lisp (sbcl 2.6.3) |
| 結果 |
AC
|
| 実行時間 | 22 ms / 2,000 ms |
| コード長 | 1,009 bytes |
| 記録 | |
| コンパイル時間 | 1,139 ms |
| コンパイル使用メモリ | 36,360 KB |
| 実行使用メモリ | 32,244 KB |
| 最終ジャッジ日時 | 2026-04-25 01:25:41 |
| 合計ジャッジ時間 | 2,540 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 33 |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 25 APR 2026 01:25:38 AM): ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.028
ソースコード
; ある村民が何回 nyanpass と発言したかをメモしていく
; 最後に n - 1 の数が1つだけであればそれが答え
(defun main ()
(let* ((n (read))
(memo (make-array n :initial-element 0)))
(dotimes (i n) ; i 人目の人が受けた挨拶
(dotimes (j n); j 人目の人がした挨拶
(when (eql 'nyanpass (read)); nyanpass シンボルと等しいときにメモする
(incf (aref memo j)))))
; count item sequence &key from-end start end key test test-not ⇒ n
; n - 1 回挨拶した人が一人かどうかで場合分け
(princ (if (= (count (1- n) memo) 1)
; 配列が 0 から始まっているので 1 を足す
(1+
; position item sequence &key from-end test test-not start end key ⇒ position
; n - 1 回挨拶した人の番号を探す
(position (1- n) memo))
-1))
(terpri)))
(main)
Common Lisp