結果

問題 No.346 チワワ数え上げ問題
ユーザー brthyyjpbrthyyjp
提出日時 2021-04-28 19:48:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 337 bytes
コンパイル時間 315 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 78,540 KB
最終ジャッジ日時 2023-09-22 01:55:23
合計ジャッジ時間 3,630 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,360 KB
testcase_01 AC 71 ms
71,456 KB
testcase_02 AC 70 ms
71,340 KB
testcase_03 AC 70 ms
71,584 KB
testcase_04 AC 70 ms
71,548 KB
testcase_05 AC 70 ms
71,396 KB
testcase_06 AC 69 ms
71,308 KB
testcase_07 AC 69 ms
71,352 KB
testcase_08 AC 70 ms
71,600 KB
testcase_09 AC 71 ms
71,312 KB
testcase_10 AC 85 ms
78,344 KB
testcase_11 AC 82 ms
76,952 KB
testcase_12 AC 84 ms
78,272 KB
testcase_13 AC 84 ms
77,096 KB
testcase_14 AC 77 ms
76,224 KB
testcase_15 AC 83 ms
77,288 KB
testcase_16 AC 87 ms
78,184 KB
testcase_17 AC 85 ms
78,344 KB
testcase_18 AC 90 ms
78,392 KB
testcase_19 AC 84 ms
78,028 KB
testcase_20 AC 79 ms
77,756 KB
testcase_21 AC 87 ms
78,376 KB
testcase_22 AC 87 ms
78,540 KB
testcase_23 AC 68 ms
71,456 KB
testcase_24 AC 70 ms
71,460 KB
testcase_25 AC 70 ms
71,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

s = str(input())
n = len(s)
C = [0]*(n+1)
W = [0]*(n+1)
for i, c in enumerate(s):
    if c == 'c':
        C[i] += 1
    if c == 'w':
        W[i] += 1

for i in range(1, n+1):
    C[i] += C[i-1]

for i in reversed(range(n-1)):
    W[i] += W[i+1]

ans = 0
for i, c in enumerate(s):
    if c == 'w':
        ans += C[i]*W[i+1]
print(ans)
0