結果

問題 No.852 連続部分文字列
ユーザー OKCH3COOHOKCH3COOH
提出日時 2019-10-30 10:15:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 455 bytes
コンパイル時間 146 ms
コンパイル使用メモリ 10,568 KB
実行使用メモリ 22,084 KB
最終ジャッジ日時 2023-10-12 23:41:11
合計ジャッジ時間 25,870 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
12,280 KB
testcase_01 AC 15 ms
7,968 KB
testcase_02 AC 16 ms
7,828 KB
testcase_03 AC 16 ms
7,800 KB
testcase_04 AC 16 ms
7,796 KB
testcase_05 AC 18 ms
7,756 KB
testcase_06 AC 16 ms
7,792 KB
testcase_07 AC 17 ms
7,868 KB
testcase_08 AC 16 ms
7,928 KB
testcase_09 AC 16 ms
7,844 KB
testcase_10 AC 16 ms
7,928 KB
testcase_11 AC 17 ms
7,800 KB
testcase_12 AC 16 ms
7,828 KB
testcase_13 AC 822 ms
8,192 KB
testcase_14 AC 333 ms
7,888 KB
testcase_15 AC 1,301 ms
8,400 KB
testcase_16 AC 742 ms
8,088 KB
testcase_17 AC 1,046 ms
8,124 KB
testcase_18 AC 1,395 ms
8,300 KB
testcase_19 AC 105 ms
7,828 KB
testcase_20 AC 598 ms
8,080 KB
testcase_21 AC 1,405 ms
8,292 KB
testcase_22 AC 430 ms
8,044 KB
testcase_23 AC 966 ms
8,092 KB
testcase_24 AC 546 ms
8,180 KB
testcase_25 AC 902 ms
8,188 KB
testcase_26 AC 1,344 ms
8,280 KB
testcase_27 AC 792 ms
8,192 KB
testcase_28 AC 1,056 ms
8,100 KB
testcase_29 AC 1,371 ms
8,268 KB
testcase_30 AC 248 ms
7,796 KB
testcase_31 AC 1,441 ms
8,300 KB
testcase_32 AC 1,532 ms
8,088 KB
testcase_33 TLE -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()
N = len(S)

# 左からi文字目移行の文字数 [i, N]
maxSize = [0] * (N + 1)
V = set()
for i, s in enumerate(S[:: -1], start=2):
    V.add(s)
    maxSize[-i] = len(V)

ans = 0
for left, s in enumerate(S):
    V = set()
    for right, t in enumerate(S[left:], start=left):
        V.add(t)
        if len(V) == maxSize[left]:
            ans += len(V) * (N - right)
            break
        ans += len(V)

print(ans / (N * (N + 1) // 2))
0