結果

問題 No.852 連続部分文字列
ユーザー 6soukiti296soukiti29
提出日時 2019-07-27 13:47:09
言語 Nim
(2.0.2)
結果
AC  
実行時間 589 ms / 3,153 ms
コード長 549 bytes
コンパイル時間 8,208 ms
コンパイル使用メモリ 68,256 KB
実行使用メモリ 22,596 KB
最終ジャッジ日時 2023-09-15 06:15:37
合計ジャッジ時間 11,587 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,384 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 12 ms
4,384 KB
testcase_14 AC 6 ms
4,376 KB
testcase_15 AC 19 ms
4,488 KB
testcase_16 AC 12 ms
4,380 KB
testcase_17 AC 16 ms
4,380 KB
testcase_18 AC 19 ms
4,512 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 AC 9 ms
4,384 KB
testcase_21 AC 20 ms
4,556 KB
testcase_22 AC 7 ms
4,376 KB
testcase_23 AC 14 ms
4,380 KB
testcase_24 AC 8 ms
4,380 KB
testcase_25 AC 13 ms
4,380 KB
testcase_26 AC 19 ms
4,512 KB
testcase_27 AC 13 ms
4,380 KB
testcase_28 AC 15 ms
4,384 KB
testcase_29 AC 20 ms
4,488 KB
testcase_30 AC 5 ms
4,376 KB
testcase_31 AC 21 ms
4,592 KB
testcase_32 AC 21 ms
4,488 KB
testcase_33 AC 589 ms
22,176 KB
testcase_34 AC 577 ms
22,208 KB
testcase_35 AC 583 ms
22,596 KB
testcase_36 AC 587 ms
22,380 KB
testcase_37 AC 585 ms
21,628 KB
testcase_38 AC 587 ms
22,340 KB
testcase_39 AC 582 ms
22,576 KB
testcase_40 AC 579 ms
21,364 KB
testcase_41 AC 583 ms
21,616 KB
testcase_42 AC 585 ms
21,812 KB
testcase_43 AC 576 ms
16,836 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'sequtils' [UnusedImport]
/home/judge/data/code/Main.nim(1, 17) Warning: imported and not used: 'strutils' [UnusedImport]
/home/judge/data/code/Main.nim(1, 26) Warning: imported and not used: 'math' [UnusedImport]
/home/judge/data/code/Main.nim(1, 31) Warning: imported and not used: 'algorithm' [UnusedImport]

ソースコード

diff #

import sequtils,strutils,math,algorithm
var
    S = stdin.readline
    A : array['a'..'z', seq[int]]
    P : array['a'..'z', int]
    ans : float64 = 0.0
    q = 0.0
    
for c in 'a'..'z':
    A[c] = @[]

for i, c in S:
    A[c].add(i)

for i in 0..S.high:
    var B = newSeq[int](0)
    for c in 'a'..'z':
        if A[c].high < P[c]:
            continue
        B.add(A[c][P[c]] - i)
        if c == S[i]:
            P[c] += 1
    for j in 0..B.high:
        ans += (S.high - i + 1 - B[j]).float64
    q += (S.high - i + 1).float64
echo ans / q
0