結果

問題 No.852 連続部分文字列
ユーザー kurimupykurimupy
提出日時 2020-06-18 12:17:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 269 ms / 3,153 ms
コード長 407 bytes
コンパイル時間 395 ms
コンパイル使用メモリ 87,240 KB
実行使用メモリ 160,312 KB
最終ジャッジ日時 2023-09-16 12:01:19
合計ジャッジ時間 7,874 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,384 KB
testcase_01 AC 71 ms
71,400 KB
testcase_02 AC 71 ms
71,400 KB
testcase_03 AC 71 ms
71,244 KB
testcase_04 AC 74 ms
71,192 KB
testcase_05 AC 73 ms
71,060 KB
testcase_06 AC 69 ms
71,096 KB
testcase_07 AC 70 ms
71,388 KB
testcase_08 AC 74 ms
71,384 KB
testcase_09 AC 70 ms
71,404 KB
testcase_10 AC 74 ms
71,072 KB
testcase_11 AC 72 ms
71,296 KB
testcase_12 AC 72 ms
71,240 KB
testcase_13 AC 80 ms
76,092 KB
testcase_14 AC 77 ms
76,180 KB
testcase_15 AC 82 ms
76,660 KB
testcase_16 AC 81 ms
76,264 KB
testcase_17 AC 82 ms
76,652 KB
testcase_18 AC 87 ms
76,936 KB
testcase_19 AC 79 ms
76,496 KB
testcase_20 AC 80 ms
76,012 KB
testcase_21 AC 87 ms
76,784 KB
testcase_22 AC 81 ms
76,136 KB
testcase_23 AC 81 ms
76,504 KB
testcase_24 AC 79 ms
76,052 KB
testcase_25 AC 80 ms
76,316 KB
testcase_26 AC 86 ms
76,688 KB
testcase_27 AC 81 ms
76,488 KB
testcase_28 AC 81 ms
76,376 KB
testcase_29 AC 85 ms
76,644 KB
testcase_30 AC 80 ms
76,452 KB
testcase_31 AC 83 ms
76,756 KB
testcase_32 AC 86 ms
76,820 KB
testcase_33 AC 268 ms
157,940 KB
testcase_34 AC 263 ms
157,452 KB
testcase_35 AC 261 ms
157,620 KB
testcase_36 AC 265 ms
157,484 KB
testcase_37 AC 266 ms
157,460 KB
testcase_38 AC 269 ms
157,988 KB
testcase_39 AC 264 ms
157,516 KB
testcase_40 AC 265 ms
157,604 KB
testcase_41 AC 266 ms
157,500 KB
testcase_42 AC 269 ms
160,312 KB
testcase_43 AC 259 ms
157,708 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = list(input())
N = len(S)
alpha = "abcdefghijklmnopqrstuvwxyz"
d = {alpha[i]: [0] for i in range(26)}
for i in range(N):
    d[S[i]].append(i+1)
for i in range(26):
    d[alpha[i]].append(N+1)
ans = 0
down = N*(N+1)//2
for i in range(26):
    P = N*(N+1)//2
    for j in range(len(d[alpha[i]])-1):
        x, y = d[alpha[i]][j], d[alpha[i]][j+1]
        P -= (y-x)*(y-x-1)//2
    ans += P/down
print(ans)
0