結果

問題 No.852 連続部分文字列
ユーザー maspymaspy
提出日時 2020-02-19 15:52:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 749 ms / 3,153 ms
コード長 447 bytes
コンパイル時間 100 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 50,364 KB
最終ジャッジ日時 2024-04-16 22:04:03
合計ジャッジ時間 28,714 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 529 ms
43,680 KB
testcase_01 AC 529 ms
43,804 KB
testcase_02 AC 528 ms
44,064 KB
testcase_03 AC 529 ms
43,808 KB
testcase_04 AC 531 ms
43,684 KB
testcase_05 AC 530 ms
43,812 KB
testcase_06 AC 530 ms
44,072 KB
testcase_07 AC 530 ms
43,804 KB
testcase_08 AC 529 ms
44,060 KB
testcase_09 AC 540 ms
44,072 KB
testcase_10 AC 540 ms
43,808 KB
testcase_11 AC 529 ms
43,808 KB
testcase_12 AC 528 ms
44,064 KB
testcase_13 AC 531 ms
44,324 KB
testcase_14 AC 527 ms
43,804 KB
testcase_15 AC 531 ms
44,064 KB
testcase_16 AC 534 ms
44,320 KB
testcase_17 AC 534 ms
43,816 KB
testcase_18 AC 535 ms
44,064 KB
testcase_19 AC 527 ms
44,452 KB
testcase_20 AC 524 ms
43,808 KB
testcase_21 AC 528 ms
44,068 KB
testcase_22 AC 518 ms
43,940 KB
testcase_23 AC 524 ms
43,808 KB
testcase_24 AC 529 ms
43,804 KB
testcase_25 AC 520 ms
43,804 KB
testcase_26 AC 521 ms
43,816 KB
testcase_27 AC 525 ms
44,076 KB
testcase_28 AC 529 ms
43,932 KB
testcase_29 AC 534 ms
44,064 KB
testcase_30 AC 528 ms
43,808 KB
testcase_31 AC 521 ms
44,076 KB
testcase_32 AC 525 ms
43,808 KB
testcase_33 AC 749 ms
46,248 KB
testcase_34 AC 685 ms
46,228 KB
testcase_35 AC 688 ms
46,380 KB
testcase_36 AC 689 ms
46,500 KB
testcase_37 AC 693 ms
46,508 KB
testcase_38 AC 683 ms
46,240 KB
testcase_39 AC 688 ms
46,240 KB
testcase_40 AC 687 ms
46,236 KB
testcase_41 AC 681 ms
46,500 KB
testcase_42 AC 666 ms
45,348 KB
testcase_43 AC 682 ms
50,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# %%
stdin = open(0)

# %%
import numpy as np


# %%
S = np.frombuffer(stdin.buffer.read().rstrip(), 'S1')


# %%
n = len(S)
total = n * (n + 1) // 2
numerator = 0
for i in range(26):
    alphabet = chr(ord('a') + i).encode()
    ind = np.hstack([[-1], np.where(S == alphabet)[0], [n]])
    gaps = ind[1:] - ind[:-1] - 1
    numerator += total - (gaps * (gaps + 1) // 2).sum()

# %%
answer = numerator / total
print(answer)
0