結果

問題 No.852 連続部分文字列
ユーザー brthyyjpbrthyyjp
提出日時 2020-08-05 00:31:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 399 ms / 3,153 ms
コード長 372 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 87,280 KB
実行使用メモリ 131,636 KB
最終ジャッジ日時 2023-10-13 03:28:01
合計ジャッジ時間 9,755 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,488 KB
testcase_01 AC 73 ms
71,372 KB
testcase_02 AC 76 ms
71,160 KB
testcase_03 AC 72 ms
71,164 KB
testcase_04 AC 73 ms
71,384 KB
testcase_05 AC 76 ms
75,900 KB
testcase_06 AC 77 ms
75,868 KB
testcase_07 AC 78 ms
75,900 KB
testcase_08 AC 76 ms
71,628 KB
testcase_09 AC 72 ms
71,524 KB
testcase_10 AC 75 ms
75,948 KB
testcase_11 AC 71 ms
71,380 KB
testcase_12 AC 75 ms
75,904 KB
testcase_13 AC 80 ms
76,420 KB
testcase_14 AC 81 ms
76,372 KB
testcase_15 AC 89 ms
76,396 KB
testcase_16 AC 81 ms
76,408 KB
testcase_17 AC 82 ms
76,484 KB
testcase_18 AC 86 ms
76,440 KB
testcase_19 AC 79 ms
76,400 KB
testcase_20 AC 80 ms
76,364 KB
testcase_21 AC 84 ms
76,476 KB
testcase_22 AC 82 ms
76,228 KB
testcase_23 AC 83 ms
76,420 KB
testcase_24 AC 82 ms
76,436 KB
testcase_25 AC 81 ms
76,384 KB
testcase_26 AC 84 ms
76,288 KB
testcase_27 AC 83 ms
76,472 KB
testcase_28 AC 85 ms
76,464 KB
testcase_29 AC 87 ms
76,612 KB
testcase_30 AC 81 ms
76,404 KB
testcase_31 AC 87 ms
76,340 KB
testcase_32 AC 89 ms
76,484 KB
testcase_33 AC 271 ms
107,708 KB
testcase_34 AC 274 ms
107,432 KB
testcase_35 AC 273 ms
107,476 KB
testcase_36 AC 273 ms
107,692 KB
testcase_37 AC 272 ms
107,772 KB
testcase_38 AC 275 ms
107,504 KB
testcase_39 AC 399 ms
104,692 KB
testcase_40 AC 272 ms
104,536 KB
testcase_41 AC 273 ms
107,664 KB
testcase_42 AC 395 ms
110,508 KB
testcase_43 AC 289 ms
131,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

s = str(input())

n = len(s)
ans = 0
for i in range(26):
    c = chr(i+ord('a'))
    X = []
    cnt = 0
    for j in range(n):
        if s[j] != c:
            cnt += 1
        else:
            X.append(cnt)
            cnt = 0
    else:
        X.append(cnt)
    temp = n*(n+1)//2
    for x in X:
        temp -= x*(x+1)//2
    ans += temp
ans /= n*(n+1)//2
print(ans)
0