結果

問題 No.2419 MMA文字列2
ユーザー maru65536maru65536
提出日時 2023-08-12 14:02:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 530 ms / 2,000 ms
コード長 273 bytes
コンパイル時間 356 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 72,532 KB
最終ジャッジ日時 2024-04-30 04:45:48
合計ジャッジ時間 8,246 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,496 KB
testcase_01 AC 25 ms
10,624 KB
testcase_02 AC 24 ms
10,624 KB
testcase_03 AC 25 ms
10,624 KB
testcase_04 AC 25 ms
10,752 KB
testcase_05 AC 30 ms
10,752 KB
testcase_06 AC 24 ms
10,624 KB
testcase_07 AC 25 ms
10,624 KB
testcase_08 AC 26 ms
10,624 KB
testcase_09 AC 24 ms
10,624 KB
testcase_10 AC 24 ms
10,624 KB
testcase_11 AC 24 ms
10,624 KB
testcase_12 AC 124 ms
24,320 KB
testcase_13 AC 38 ms
12,416 KB
testcase_14 AC 209 ms
37,120 KB
testcase_15 AC 134 ms
26,752 KB
testcase_16 AC 248 ms
38,400 KB
testcase_17 AC 84 ms
18,816 KB
testcase_18 AC 249 ms
39,296 KB
testcase_19 AC 253 ms
40,320 KB
testcase_20 AC 92 ms
19,840 KB
testcase_21 AC 71 ms
16,768 KB
testcase_22 AC 503 ms
72,532 KB
testcase_23 AC 530 ms
72,532 KB
testcase_24 AC 500 ms
72,532 KB
testcase_25 AC 515 ms
72,400 KB
testcase_26 AC 75 ms
18,048 KB
testcase_27 AC 487 ms
72,404 KB
testcase_28 AC 525 ms
72,272 KB
testcase_29 AC 512 ms
72,408 KB
testcase_30 AC 506 ms
72,276 KB
testcase_31 AC 501 ms
72,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

s=input()
n=len(s)
cum=[[0]*26]
for i,c in enumerate(s):
    tmp=cum[-1][:]
    tmp[ord(c)-ord('A')]+=1
    cum.append(tmp)
ans=0
for i,c in enumerate(s):
    ima_c=cum[i][ord(c)-ord('A')]
    zenbu_c=cum[-1][ord(c) - ord('A')]
    ans+=ima_c*(n-i-zenbu_c+ima_c)
print(ans)
0