結果

問題 No.1972 Modulo Set
ユーザー n_getn_get
提出日時 2022-07-16 16:05:03
言語 Scheme
(Gauche-0.9.14)
結果
WA  
実行時間 -
コード長 2,707 bytes
コンパイル時間 336 ms
コンパイル使用メモリ 7,092 KB
実行使用メモリ 22,304 KB
最終ジャッジ日時 2023-09-11 01:04:44
合計ジャッジ時間 10,122 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
14,812 KB
testcase_01 AC 42 ms
14,956 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 99 ms
18,504 KB
testcase_29 AC 136 ms
19,100 KB
testcase_30 AC 161 ms
18,688 KB
testcase_31 AC 47 ms
14,816 KB
testcase_32 AC 151 ms
18,492 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

(use util.queue)(use util.match)(use gauche.collection)(use gauche.sequence)
(define-syntax def-syntax (syntax-rules()((_ v e ...)(define-syntax v (syntax-rules e ...)))))
(define-syntax def-const define-constant)(define-syntax def define)(define-syntax def-inline define-inline)
(def-syntax def-names ()((_[x y]...)(begin(define-constant x y)...)))
(def-names [// quotient][% modulo][v-make make-vector][v-ref vector-ref][v-set! vector-set!][ht-make make-hash-table][ht-ref hash-table-get][ht-set! hash-table-put!][ht-keys hash-table-keys][ht-values hash-table-values][q-make make-queue][make-q make-queue][enq! enqueue!][deq! dequeue!][q-empty? queue-empty?])

(def-syntax input (: list vec cons str)
  ((_ : cons e ...)(cons(input : e ...)(input : e ...)))((_ : list str)(input : string->list str))
  ((_ : vec str)(input : string->vector str))((_ : vec n e ...)(vector-tabulate n(^_(input : e ...))))
  ((_ : list n e ...)(let l([k n])(if(zero? k)'()(cons(input : e ...)(l(- k 1))))))((_ :)(read))((_ : : e)e)
  ((_ : str)(let1 s(read-line)(if(string=? s "")(read-line)s)))((_[[v]: e ...])(def v(input : e ...)))
  ((_[[v w ...]: e ...])(begin(def v(input : e ...))(input[[w ...]: e ...])))
  ((_[v : e ...])(def v(input : e ...)))((_ : op e ...)(op(input : e ...)))
  ((_(e ...))(e ...))((_ v)(def v(read)))((_ e ...)(begin(input e)...)))

(def-syntax for [in to with]
  ((_[i N]e ...)(dotimes [i N] e ...))
  ((_[i A to B]e ...)
   (let[[a A][b B]](if (< A B)(let loop[[i a]] e ... (when (< i b) (loop (+ i 1))))
                       (let loop[[i a]] e ... (when (> i b) (loop (- i 1)))))))
  ((_[[x ...]in[A ...]with i]e ...)(for-each-with-index(^(i x ...)e ...)A ...))
  ((_[[x ...]in[A ...]]e ...)(for-each(^(x ...)e ...)A ...))
  ((_[x in A with i]e ...)(for-each-with-index(^(i x)e ...)A))
  ((_[x in A]e ...)(for-each(^(x) e ...)A))
  ((_[k v in H]e ...)(hash-table-for-each(^(k v)e ...))))


(define-constant *MOD* 1000000007)
;(define-constant *MOD* 998244353)
(def-syntax add-mod! ()((_ v x)(let1 y(+ v x)(set! v(if(< y *MOD*)y(- y *MOD*))))))
(def-inline(v-add-mod! v i x)(let1 y(+(v-ref v i)x)(v-set! v i(if(< y *MOD*)y(- y *MOD*)))))
(def-syntax max! ()((_ v x)(set! v (max x v)))) (def-syntax min! ()((_ v x)(set! v (min x v))))
(def-inline(v-add! v i x)(v-set! v i(+ x(v-ref v i))))
(def-inline(ht-add! ht i x)(ht-set! ht i(+ x(ht-ref ht i 0))))
(def-inline(ht-cons! ht i x)(ht-set! ht i(cons x(ht-ref ht i '()))))
(def-syntax return () ((_ e ...) (begin (print e ...) (exit))))


;; 以下スニペットのコピペ


;; 以下が本体

(input N M [A : vec N])
(def ht (make-hash-table))
(for [a in A]
  (ht-set! ht (min (mod a M) (- M (mod a M))) #t))
(print (hash-table-size ht))
0