結果

問題 No.852 連続部分文字列
ユーザー roarisroaris
提出日時 2019-07-27 01:51:30
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 345 bytes
コンパイル時間 437 ms
コンパイル使用メモリ 10,732 KB
実行使用メモリ 90,892 KB
最終ジャッジ日時 2023-09-15 05:29:10
合計ジャッジ時間 13,776 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,444 KB
testcase_01 AC 19 ms
8,324 KB
testcase_02 AC 18 ms
8,320 KB
testcase_03 WA -
testcase_04 AC 18 ms
8,432 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 19 ms
8,452 KB
testcase_10 AC 18 ms
8,400 KB
testcase_11 WA -
testcase_12 AC 19 ms
8,360 KB
testcase_13 AC 33 ms
9,720 KB
testcase_14 WA -
testcase_15 AC 42 ms
10,612 KB
testcase_16 AC 32 ms
9,632 KB
testcase_17 AC 38 ms
10,236 KB
testcase_18 AC 44 ms
10,652 KB
testcase_19 WA -
testcase_20 AC 29 ms
9,528 KB
testcase_21 AC 44 ms
10,748 KB
testcase_22 AC 27 ms
9,140 KB
testcase_23 AC 36 ms
9,956 KB
testcase_24 AC 28 ms
9,424 KB
testcase_25 AC 35 ms
9,860 KB
testcase_26 AC 43 ms
10,664 KB
testcase_27 AC 33 ms
9,816 KB
testcase_28 AC 38 ms
10,256 KB
testcase_29 AC 43 ms
10,800 KB
testcase_30 WA -
testcase_31 AC 44 ms
10,936 KB
testcase_32 AC 46 ms
10,980 KB
testcase_33 AC 943 ms
90,528 KB
testcase_34 AC 906 ms
90,648 KB
testcase_35 AC 897 ms
90,496 KB
testcase_36 AC 985 ms
90,892 KB
testcase_37 AC 906 ms
90,208 KB
testcase_38 AC 957 ms
90,284 KB
testcase_39 AC 897 ms
90,880 KB
testcase_40 AC 903 ms
90,288 KB
testcase_41 AC 944 ms
90,552 KB
testcase_42 AC 912 ms
90,048 KB
testcase_43 AC 889 ms
89,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

S = input()
N = len(S)
dp = [0] * N
dp[0] = 1
appear_dict = defaultdict(list)

for i in range(1, N):
    if len(appear_dict[S[i]]) == 0:
        dp[i] = dp[i-1] + i + 1
    else:
        dp[i] = dp[i-1] + i - appear_dict[S[i]][-1]
    
    appear_dict[S[i]].append(i)

ans = sum(dp) / (N*(N+1)/2)
print(ans)
0