結果

問題 No.274 The Wall
ユーザー RinRin
提出日時 2015-09-02 17:40:06
言語 Scheme
(Gauche-0.9.14)
結果
TLE  
実行時間 -
コード長 1,943 bytes
コンパイル時間 265 ms
コンパイル使用メモリ 5,332 KB
実行使用メモリ 19,884 KB
最終ジャッジ日時 2023-09-26 02:12:17
合計ジャッジ時間 5,062 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
16,036 KB
testcase_01 AC 48 ms
13,720 KB
testcase_02 AC 78 ms
13,948 KB
testcase_03 AC 25 ms
13,164 KB
testcase_04 AC 18 ms
11,760 KB
testcase_05 AC 19 ms
11,764 KB
testcase_06 AC 18 ms
11,768 KB
testcase_07 AC 18 ms
11,896 KB
testcase_08 AC 19 ms
11,764 KB
testcase_09 AC 61 ms
13,720 KB
testcase_10 AC 60 ms
12,536 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

(define (System.out.println x)
  (begin
    (display x)
    (newline)
  )
)

(define (make-column M For To)
  (let loop(
            (i 0)
            (foo '())
           )
    (if (and (>= i For) (<= i To))
        (if (< i M)
            (loop (+ i 1) (cons 1 foo))
            (cons 1 foo)
        )
        (if (< i M)
            (loop (+ i 1) (cons 0 foo))
            (cons 0 foo)
        )
    )
  )
)

(define (find2 ls)
  (let loop(
            (i 0)
           )
    (if (= i (length ls))
        #f
        (if (= (list-ref ls i) 2)
            #t
            (loop (+ i 1))
        )
    )
  )
)


(let (
      (N (read))
      (M (- (read) 1))
      (UsedColumn '())
      (Possible? "YES")
     )
  (let loop(
            (i 1)
            (For (read))
            (To  (read))
           )
    (let (
          (column (make-column M For To))
         )
      (if (null? UsedColumn)
          (begin
            (set! UsedColumn column)
            (loop 2 (read) (read))
          )
          (if (find2 (map + UsedColumn column))
              (if (find2 (map + UsedColumn (reverse column)))
                  (begin
                    (set! Possible? "NO")
                    (if (= i N)
                        (System.out.println Possible?)
                        (loop (+ i 1) (read) (read))
                    )
                  )
                  (if (= i N)
                      (System.out.println Possible?)
                      (begin
                        (set! UsedColumn (map + UsedColumn (reverse column)))
                        (loop (+ i 1) (read) (read))
                      )
                  )
              )
              (if (= i N)
                  (System.out.println Possible?)
                  (begin
                    (set! UsedColumn (map + UsedColumn column))
                    (loop (+ i 1) (read) (read))
                  )
              )
          )
      )
    )
  )
)
0