結果

問題 No.346 チワワ数え上げ問題
ユーザー ronpooronpoo
提出日時 2023-08-23 20:30:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 271 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 87,156 KB
実行使用メモリ 83,196 KB
最終ジャッジ日時 2023-08-23 20:30:17
合計ジャッジ時間 3,832 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,176 KB
testcase_01 AC 73 ms
71,452 KB
testcase_02 AC 73 ms
71,408 KB
testcase_03 AC 71 ms
71,452 KB
testcase_04 AC 74 ms
71,304 KB
testcase_05 AC 73 ms
71,200 KB
testcase_06 AC 75 ms
71,180 KB
testcase_07 AC 74 ms
71,088 KB
testcase_08 AC 73 ms
71,288 KB
testcase_09 AC 73 ms
71,036 KB
testcase_10 AC 79 ms
77,120 KB
testcase_11 AC 80 ms
76,568 KB
testcase_12 AC 81 ms
77,004 KB
testcase_13 AC 81 ms
76,740 KB
testcase_14 AC 77 ms
75,828 KB
testcase_15 AC 79 ms
76,640 KB
testcase_16 AC 79 ms
76,860 KB
testcase_17 AC 82 ms
76,992 KB
testcase_18 AC 85 ms
77,056 KB
testcase_19 AC 81 ms
77,004 KB
testcase_20 AC 85 ms
83,196 KB
testcase_21 AC 82 ms
79,532 KB
testcase_22 AC 84 ms
79,656 KB
testcase_23 AC 71 ms
71,584 KB
testcase_24 AC 70 ms
71,512 KB
testcase_25 AC 73 ms
71,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()
L = len(S)

c = []
wcnt = [0] * L
for i in range(L-1, -1, -1):
    if i != L-1:
        wcnt[i] = wcnt[i+1]
    if S[i] == 'w':
        wcnt[i] += 1
    elif S[i] == 'c':
        c.append(i)
ans = 0
for i in c:
    ans += wcnt[i] * (wcnt[i]-1) // 2
print(ans)
0