結果

問題 No.852 連続部分文字列
ユーザー 双六双六
提出日時 2020-07-22 16:18:51
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 325 ms / 3,153 ms
コード長 589 bytes
コンパイル時間 383 ms
コンパイル使用メモリ 10,828 KB
実行使用メモリ 10,460 KB
最終ジャッジ日時 2023-09-02 20:08:59
合計ジャッジ時間 7,568 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,368 KB
testcase_01 AC 18 ms
8,420 KB
testcase_02 AC 18 ms
8,384 KB
testcase_03 AC 18 ms
8,380 KB
testcase_04 AC 18 ms
8,380 KB
testcase_05 AC 18 ms
8,360 KB
testcase_06 AC 18 ms
8,368 KB
testcase_07 AC 18 ms
8,308 KB
testcase_08 AC 18 ms
8,436 KB
testcase_09 AC 18 ms
8,528 KB
testcase_10 AC 18 ms
8,392 KB
testcase_11 AC 18 ms
8,308 KB
testcase_12 AC 19 ms
8,440 KB
testcase_13 AC 23 ms
8,412 KB
testcase_14 AC 20 ms
8,308 KB
testcase_15 AC 27 ms
8,592 KB
testcase_16 AC 23 ms
8,416 KB
testcase_17 AC 26 ms
8,436 KB
testcase_18 AC 27 ms
8,500 KB
testcase_19 AC 18 ms
8,388 KB
testcase_20 AC 22 ms
8,548 KB
testcase_21 AC 28 ms
8,432 KB
testcase_22 AC 21 ms
8,520 KB
testcase_23 AC 25 ms
8,448 KB
testcase_24 AC 22 ms
8,472 KB
testcase_25 AC 24 ms
8,420 KB
testcase_26 AC 27 ms
8,532 KB
testcase_27 AC 24 ms
8,484 KB
testcase_28 AC 26 ms
8,520 KB
testcase_29 AC 27 ms
8,476 KB
testcase_30 AC 20 ms
8,388 KB
testcase_31 AC 28 ms
8,396 KB
testcase_32 AC 28 ms
8,520 KB
testcase_33 AC 322 ms
10,424 KB
testcase_34 AC 321 ms
10,356 KB
testcase_35 AC 323 ms
10,248 KB
testcase_36 AC 325 ms
10,304 KB
testcase_37 AC 320 ms
10,460 KB
testcase_38 AC 321 ms
10,412 KB
testcase_39 AC 323 ms
10,212 KB
testcase_40 AC 321 ms
10,448 KB
testcase_41 AC 320 ms
10,296 KB
testcase_42 AC 317 ms
10,332 KB
testcase_43 AC 325 ms
10,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# import sys; input = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	S = input()
	N = len(S)
	pre = [-1] * 26
	minus = 0
	for i in range(N):
		a = ord(S[i]) - 97
		num = i - pre[a] - 1
		minus += int(num * (num + 1) // 2)
		pre[a] = i

	for i in range(26):
		minus += int((N - 1 - pre[i]) * (N - pre[i]) // 2)

	# print(minus)

	ans = 26 - minus / (int(N * (N + 1) // 2))
	print(ans)



if __name__ == '__main__':
	main()
0