結果

問題 No.852 連続部分文字列
ユーザー H3PO4H3PO4
提出日時 2021-02-26 09:17:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 582 ms / 3,153 ms
コード長 230 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 50,936 KB
最終ジャッジ日時 2024-04-09 22:31:09
合計ジャッジ時間 8,730 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
10,496 KB
testcase_01 AC 24 ms
10,496 KB
testcase_02 AC 24 ms
10,496 KB
testcase_03 AC 24 ms
10,496 KB
testcase_04 AC 24 ms
10,496 KB
testcase_05 AC 23 ms
10,624 KB
testcase_06 AC 24 ms
10,496 KB
testcase_07 AC 24 ms
10,496 KB
testcase_08 AC 23 ms
10,496 KB
testcase_09 AC 24 ms
10,496 KB
testcase_10 AC 28 ms
10,496 KB
testcase_11 AC 27 ms
10,496 KB
testcase_12 AC 28 ms
10,624 KB
testcase_13 AC 37 ms
11,264 KB
testcase_14 AC 29 ms
10,880 KB
testcase_15 AC 39 ms
11,648 KB
testcase_16 AC 33 ms
11,264 KB
testcase_17 AC 36 ms
11,520 KB
testcase_18 AC 41 ms
11,776 KB
testcase_19 AC 25 ms
10,624 KB
testcase_20 AC 31 ms
11,008 KB
testcase_21 AC 40 ms
11,776 KB
testcase_22 AC 32 ms
10,880 KB
testcase_23 AC 40 ms
11,392 KB
testcase_24 AC 33 ms
11,136 KB
testcase_25 AC 34 ms
11,392 KB
testcase_26 AC 39 ms
11,776 KB
testcase_27 AC 33 ms
11,264 KB
testcase_28 AC 37 ms
11,520 KB
testcase_29 AC 40 ms
11,776 KB
testcase_30 AC 28 ms
10,752 KB
testcase_31 AC 41 ms
11,904 KB
testcase_32 AC 45 ms
11,904 KB
testcase_33 AC 546 ms
50,800 KB
testcase_34 AC 538 ms
50,848 KB
testcase_35 AC 539 ms
50,840 KB
testcase_36 AC 582 ms
50,936 KB
testcase_37 AC 547 ms
50,804 KB
testcase_38 AC 567 ms
50,796 KB
testcase_39 AC 550 ms
50,852 KB
testcase_40 AC 551 ms
50,840 KB
testcase_41 AC 561 ms
50,840 KB
testcase_42 AC 542 ms
50,908 KB
testcase_43 AC 570 ms
50,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

en2asc = lambda s: ord(s) - 97

S = input()
L = len(S)
cur = [-1] * 26
dp = [0] * (L + 1)
for i, s in enumerate(S):
    x = en2asc(s)
    dp[i + 1] = dp[i] + i - cur[x]
    cur[x] = i

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