結果
問題 | No.1994 Confusing Name |
ユーザー | n_get |
提出日時 | 2022-07-01 22:16:44 |
言語 | Scheme (Gauche-0.9.14) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 2,699 bytes |
コンパイル時間 | 112 ms |
コンパイル使用メモリ | 6,688 KB |
実行使用メモリ | 79,780 KB |
最終ジャッジ日時 | 2024-05-04 16:39:35 |
合計ジャッジ時間 | 25,451 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 35 ms
18,816 KB |
testcase_01 | AC | 34 ms
18,816 KB |
testcase_02 | AC | 35 ms
19,072 KB |
testcase_03 | AC | 33 ms
19,072 KB |
testcase_04 | AC | 36 ms
19,072 KB |
testcase_05 | AC | 44 ms
19,072 KB |
testcase_06 | AC | 54 ms
20,480 KB |
testcase_07 | AC | 37 ms
18,816 KB |
testcase_08 | AC | 49 ms
19,840 KB |
testcase_09 | AC | 57 ms
20,480 KB |
testcase_10 | AC | 44 ms
19,328 KB |
testcase_11 | AC | 41 ms
19,328 KB |
testcase_12 | AC | 1,479 ms
59,136 KB |
testcase_13 | AC | 1,661 ms
77,440 KB |
testcase_14 | AC | 1,614 ms
75,680 KB |
testcase_15 | AC | 1,407 ms
65,004 KB |
testcase_16 | AC | 1,174 ms
59,648 KB |
testcase_17 | AC | 1,417 ms
64,684 KB |
testcase_18 | AC | 1,684 ms
77,860 KB |
testcase_19 | TLE | - |
testcase_20 | AC | 1,635 ms
79,780 KB |
testcase_21 | AC | 376 ms
30,540 KB |
testcase_22 | AC | 193 ms
25,472 KB |
testcase_23 | AC | 1,505 ms
67,456 KB |
testcase_24 | AC | 1,476 ms
65,024 KB |
testcase_25 | AC | 932 ms
49,024 KB |
testcase_26 | AC | 547 ms
34,544 KB |
testcase_27 | AC | 1,427 ms
61,312 KB |
testcase_28 | AC | 1,040 ms
51,216 KB |
testcase_29 | AC | 159 ms
25,472 KB |
testcase_30 | AC | 1,131 ms
54,528 KB |
ソースコード
(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)...))) ;;(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 [S : list N (cut map-to <vector> char->integer <>) vec str]) (def v (make-vector 11)) (dotimes [i 11] (v-set! v i (make-vector i)) (dotimes [j i] (v-set! (v-ref v i) j (make-hash-table 'equal?)))) (def tmp 0) (dolist [s S] (let* [[n (vector-length s)] [vn (v-ref v n)]] (dotimes [i n] (set! tmp (v-ref s i)) (v-set! s i 0) (ht-add! (v-ref vn i) (vector-copy s) 1) (v-set! s i tmp)))) (def sum 0) (dolist [s S] (let* [[n (vector-length s)] [vn (v-ref v n)]] (set! sum 0) (dotimes [i n] (set! tmp (v-ref s i)) (v-set! s i 0) (inc! sum (- (ht-ref (v-ref vn i) s) 1)) (v-set! s i tmp)) (print sum)))