結果

問題 No.239 にゃんぱすー
ユーザー Common Lisp
提出日時 2024-10-08 17:51:07
言語 Common Lisp
(sbcl 2.5.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 1,009 bytes
コンパイル時間 1,012 ms
コンパイル使用メモリ 32,864 KB
実行使用メモリ 23,552 KB
最終ジャッジ日時 2024-10-08 17:51:10
合計ジャッジ時間 2,764 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 08 OCT 2024 05:51:07 PM):

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

ソースコード

diff #

; ある村民が何回 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)
0