結果

問題 No.346 チワワ数え上げ問題
ユーザー ronpoo
提出日時 2023-08-23 20:30:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 271 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 66,816 KB
最終ジャッジ日時 2024-12-22 04:49:06
合計ジャッジ時間 2,426 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

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