結果

問題 No.852 連続部分文字列
ユーザー titiatitia
提出日時 2019-07-27 00:16:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 827 ms / 3,153 ms
コード長 348 bytes
コンパイル時間 1,163 ms
コンパイル使用メモリ 87,264 KB
実行使用メモリ 281,416 KB
最終ジャッジ日時 2023-09-15 05:13:43
合計ジャッジ時間 14,205 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,380 KB
testcase_01 AC 74 ms
71,148 KB
testcase_02 AC 75 ms
71,164 KB
testcase_03 AC 74 ms
71,068 KB
testcase_04 AC 73 ms
71,272 KB
testcase_05 AC 83 ms
76,372 KB
testcase_06 AC 82 ms
76,228 KB
testcase_07 AC 82 ms
76,352 KB
testcase_08 AC 76 ms
71,524 KB
testcase_09 AC 74 ms
71,152 KB
testcase_10 AC 80 ms
76,488 KB
testcase_11 AC 74 ms
71,152 KB
testcase_12 AC 83 ms
76,368 KB
testcase_13 AC 93 ms
76,248 KB
testcase_14 AC 87 ms
76,388 KB
testcase_15 AC 104 ms
81,980 KB
testcase_16 AC 95 ms
76,384 KB
testcase_17 AC 101 ms
81,128 KB
testcase_18 AC 106 ms
82,360 KB
testcase_19 AC 85 ms
76,368 KB
testcase_20 AC 93 ms
76,524 KB
testcase_21 AC 107 ms
82,376 KB
testcase_22 AC 88 ms
76,368 KB
testcase_23 AC 98 ms
80,392 KB
testcase_24 AC 89 ms
76,312 KB
testcase_25 AC 98 ms
80,480 KB
testcase_26 AC 106 ms
82,176 KB
testcase_27 AC 94 ms
79,872 KB
testcase_28 AC 101 ms
81,160 KB
testcase_29 AC 104 ms
82,512 KB
testcase_30 AC 85 ms
76,420 KB
testcase_31 AC 107 ms
82,564 KB
testcase_32 AC 108 ms
82,852 KB
testcase_33 AC 759 ms
281,220 KB
testcase_34 AC 758 ms
281,120 KB
testcase_35 AC 753 ms
281,296 KB
testcase_36 AC 752 ms
281,248 KB
testcase_37 AC 752 ms
281,288 KB
testcase_38 AC 827 ms
281,284 KB
testcase_39 AC 753 ms
281,072 KB
testcase_40 AC 755 ms
281,216 KB
testcase_41 AC 763 ms
280,856 KB
testcase_42 AC 747 ms
281,416 KB
testcase_43 AC 747 ms
281,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S=input()
L=len(S)

M=[[1<<40]*(L+1) for i in range(26)]

for i in range(L-1,-1,-1):
    for j in range(26):
        if ord(S[i])-97==j:
            M[j][i]=i
        else:
            M[j][i]=M[j][i+1]

ANS=0

for j in range(26):
    for i in range(L):
        if M[j][i]==1<<40:
            continue
        ANS+=L-M[j][i]

print(ANS/(L*(L+1)/2))
0