結果

問題 No.852 連続部分文字列
ユーザー KoshStormKoshStorm
提出日時 2019-07-26 22:10:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,071 ms / 3,153 ms
コード長 300 bytes
コンパイル時間 699 ms
コンパイル使用メモリ 10,576 KB
実行使用メモリ 10,032 KB
最終ジャッジ日時 2023-09-15 01:49:38
合計ジャッジ時間 14,397 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
7,776 KB
testcase_01 AC 14 ms
7,804 KB
testcase_02 AC 14 ms
7,796 KB
testcase_03 AC 16 ms
7,780 KB
testcase_04 AC 14 ms
7,880 KB
testcase_05 AC 14 ms
7,828 KB
testcase_06 AC 14 ms
7,776 KB
testcase_07 AC 14 ms
7,740 KB
testcase_08 AC 14 ms
7,732 KB
testcase_09 AC 14 ms
7,824 KB
testcase_10 AC 14 ms
7,808 KB
testcase_11 AC 14 ms
7,824 KB
testcase_12 AC 15 ms
7,788 KB
testcase_13 AC 30 ms
7,816 KB
testcase_14 AC 21 ms
7,876 KB
testcase_15 AC 41 ms
8,008 KB
testcase_16 AC 30 ms
7,876 KB
testcase_17 AC 38 ms
7,816 KB
testcase_18 AC 42 ms
8,116 KB
testcase_19 AC 17 ms
7,776 KB
testcase_20 AC 27 ms
7,820 KB
testcase_21 AC 45 ms
8,016 KB
testcase_22 AC 23 ms
7,836 KB
testcase_23 AC 33 ms
7,808 KB
testcase_24 AC 25 ms
7,876 KB
testcase_25 AC 33 ms
7,776 KB
testcase_26 AC 42 ms
7,928 KB
testcase_27 AC 30 ms
7,744 KB
testcase_28 AC 38 ms
7,800 KB
testcase_29 AC 43 ms
8,020 KB
testcase_30 AC 20 ms
7,828 KB
testcase_31 AC 44 ms
7,936 KB
testcase_32 AC 46 ms
7,984 KB
testcase_33 AC 983 ms
9,872 KB
testcase_34 AC 989 ms
10,016 KB
testcase_35 AC 980 ms
9,960 KB
testcase_36 AC 1,006 ms
9,992 KB
testcase_37 AC 979 ms
10,008 KB
testcase_38 AC 1,071 ms
9,888 KB
testcase_39 AC 994 ms
9,888 KB
testcase_40 AC 990 ms
9,820 KB
testcase_41 AC 977 ms
10,004 KB
testcase_42 AC 988 ms
9,812 KB
testcase_43 AC 984 ms
10,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()

n = len(S)
total = 0
for i in range(n):
    total += (n - i) * (i + 1)

prev = set()
dic = {}
u = 0
for i in range(n):
    if S[i] in prev:
        idx = dic[S[i]]
        u += (n - i) * (idx + 1)
    prev.add(S[i])
    dic[S[i]] = i

print(round((total - u) / ((n * (n + 1)) // 2), 5))
0