結果

問題 No.852 連続部分文字列
ユーザー convexineqconvexineq
提出日時 2021-03-26 05:06:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 188 ms / 3,153 ms
コード長 241 bytes
コンパイル時間 217 ms
コンパイル使用メモリ 82,184 KB
実行使用メモリ 147,968 KB
最終ジャッジ日時 2024-11-27 14:28:28
合計ジャッジ時間 4,936 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

*s, = map(ord,input())
n = len(s)
cnt = 26*n*(n+1)//2
res = [-1]*26
for i,si in enumerate(s):
    si -= 97
    cnt -= (i-res[si])*(i-res[si]-1)//2
    res[si] = i
for i in range(26):
    cnt -= (n-res[i])*(n-res[i]-1)//2
print(cnt*2/n/(n+1))
0