結果
問題 | No.239 にゃんぱすー |
ユーザー |
![]() |
提出日時 | 2015-09-22 15:08:08 |
言語 | Scheme (Gauche-0.9.15) |
結果 |
AC
|
実行時間 | 45 ms / 2,000 ms |
コード長 | 1,315 bytes |
コンパイル時間 | 31 ms |
コンパイル使用メモリ | 5,376 KB |
実行使用メモリ | 18,688 KB |
最終ジャッジ日時 | 2024-07-19 08:37:49 |
合計ジャッジ時間 | 2,133 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
#!/usr/bin/env gosh (define (parse-input) (let ((n (read (open-input-string (read-line))))) (define (iter i acc) (if (= i 0) acc (let ((lst (read (open-input-string (string-append "(" (read-line) ")"))))) (iter (- i 1) (cons lst acc))))) (iter n '()))) (define (nyanpass lst) (define (nyanpass-pos lst acc index) (if (null? lst) acc (if (or (eq? 'nyanpass (car lst)) (eq? '- (car lst))) (nyanpass-pos (cdr lst) (cons index acc) (+ index 1)) (nyanpass-pos (cdr lst) acc (+ index 1))))) (define (renchon? n lst) (if (null? lst) #t (if (and (not (eq? 'nyanpass (list-ref (car lst) n))) (not (eq? '- (list-ref (car lst) n)))) #f (renchon? n (cdr lst))))) (define (iter maybe-renchon acc) (if (null? maybe-renchon) acc (if (renchon? (car maybe-renchon) lst) (iter (cdr maybe-renchon) (cons (+ (car maybe-renchon) 1) acc)) (iter (cdr maybe-renchon) acc)))) (iter (nyanpass-pos (car lst) '() 0) '())) (let* ((ren-list (nyanpass (parse-input)))) (if (= (length ren-list) 1) (display (car ren-list)) (display -1)) (newline))