結果

問題 No.852 連続部分文字列
ユーザー lloyzlloyz
提出日時 2022-08-23 00:55:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 351 ms / 3,153 ms
コード長 469 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 66,048 KB
最終ジャッジ日時 2024-04-18 13:58:34
合計ジャッジ時間 6,975 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
52,096 KB
testcase_01 AC 42 ms
51,968 KB
testcase_02 AC 42 ms
51,944 KB
testcase_03 AC 42 ms
51,840 KB
testcase_04 AC 43 ms
52,352 KB
testcase_05 AC 47 ms
58,240 KB
testcase_06 AC 47 ms
57,856 KB
testcase_07 AC 51 ms
58,112 KB
testcase_08 AC 44 ms
52,096 KB
testcase_09 AC 42 ms
52,096 KB
testcase_10 AC 47 ms
57,984 KB
testcase_11 AC 42 ms
52,212 KB
testcase_12 AC 46 ms
57,788 KB
testcase_13 AC 54 ms
60,672 KB
testcase_14 AC 54 ms
60,288 KB
testcase_15 AC 56 ms
60,416 KB
testcase_16 AC 55 ms
60,288 KB
testcase_17 AC 56 ms
60,416 KB
testcase_18 AC 57 ms
59,648 KB
testcase_19 AC 51 ms
59,520 KB
testcase_20 AC 54 ms
60,288 KB
testcase_21 AC 57 ms
59,776 KB
testcase_22 AC 55 ms
61,184 KB
testcase_23 AC 56 ms
60,032 KB
testcase_24 AC 52 ms
60,160 KB
testcase_25 AC 55 ms
60,032 KB
testcase_26 AC 57 ms
59,776 KB
testcase_27 AC 54 ms
59,648 KB
testcase_28 AC 57 ms
60,800 KB
testcase_29 AC 58 ms
59,904 KB
testcase_30 AC 52 ms
59,904 KB
testcase_31 AC 57 ms
60,032 KB
testcase_32 AC 59 ms
60,288 KB
testcase_33 AC 245 ms
65,664 KB
testcase_34 AC 249 ms
65,408 KB
testcase_35 AC 247 ms
64,896 KB
testcase_36 AC 248 ms
65,664 KB
testcase_37 AC 244 ms
64,896 KB
testcase_38 AC 246 ms
65,408 KB
testcase_39 AC 351 ms
65,536 KB
testcase_40 AC 241 ms
65,920 KB
testcase_41 AC 245 ms
65,664 KB
testcase_42 AC 347 ms
65,920 KB
testcase_43 AC 242 ms
66,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

alph = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

s = input()
n = len(s)
ans = 0.0
all_num = n * (n + 1) // 2
for i in range(26):
    res = 0
    cnt = 0
    for j in range(n):
        if s[j] == alph[i]:
            res += cnt * (cnt + 1) // 2
            cnt = 0
        else:
            cnt += 1
    res += cnt * (cnt + 1) // 2
    ans += (all_num - res) / all_num
print(ans)
0