結果

問題 No.852 連続部分文字列
ユーザー titiatitia
提出日時 2019-07-27 00:11:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 374 bytes
コンパイル時間 469 ms
コンパイル使用メモリ 10,984 KB
実行使用メモリ 15,948 KB
最終ジャッジ日時 2023-09-15 05:12:55
合計ジャッジ時間 15,819 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
12,148 KB
testcase_01 AC 15 ms
7,700 KB
testcase_02 AC 16 ms
7,772 KB
testcase_03 AC 16 ms
7,768 KB
testcase_04 AC 16 ms
7,820 KB
testcase_05 AC 18 ms
7,880 KB
testcase_06 AC 17 ms
7,780 KB
testcase_07 AC 17 ms
7,872 KB
testcase_08 AC 16 ms
7,832 KB
testcase_09 AC 15 ms
7,984 KB
testcase_10 AC 16 ms
7,868 KB
testcase_11 AC 16 ms
7,936 KB
testcase_12 AC 17 ms
7,824 KB
testcase_13 AC 404 ms
11,824 KB
testcase_14 AC 185 ms
9,612 KB
testcase_15 AC 653 ms
14,512 KB
testcase_16 AC 401 ms
11,792 KB
testcase_17 AC 553 ms
13,524 KB
testcase_18 AC 692 ms
14,928 KB
testcase_19 AC 60 ms
8,332 KB
testcase_20 AC 314 ms
11,036 KB
testcase_21 AC 705 ms
15,356 KB
testcase_22 AC 231 ms
10,180 KB
testcase_23 AC 483 ms
12,652 KB
testcase_24 AC 283 ms
10,712 KB
testcase_25 AC 477 ms
12,680 KB
testcase_26 AC 690 ms
15,144 KB
testcase_27 AC 406 ms
12,076 KB
testcase_28 AC 546 ms
13,388 KB
testcase_29 AC 734 ms
15,244 KB
testcase_30 AC 136 ms
9,268 KB
testcase_31 AC 741 ms
15,540 KB
testcase_32 AC 766 ms
15,948 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()
L=len(S)

M=[[float("inf")]*(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):
        k=M[j][i]-i
        if k==float("inf"):
            continue
        ANS+=(L-i)-k

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