結果

問題 No.346 チワワ数え上げ問題
ユーザー syunsukesyunsuke
提出日時 2019-09-16 11:15:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 488 bytes
コンパイル時間 346 ms
コンパイル使用メモリ 10,776 KB
実行使用メモリ 15,008 KB
最終ジャッジ日時 2023-09-21 04:22:51
合計ジャッジ時間 2,628 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,796 KB
testcase_01 AC 15 ms
7,748 KB
testcase_02 AC 16 ms
7,852 KB
testcase_03 AC 16 ms
7,748 KB
testcase_04 AC 17 ms
7,748 KB
testcase_05 AC 15 ms
7,696 KB
testcase_06 AC 16 ms
7,872 KB
testcase_07 AC 15 ms
7,876 KB
testcase_08 AC 15 ms
7,840 KB
testcase_09 AC 16 ms
7,732 KB
testcase_10 AC 68 ms
12,028 KB
testcase_11 AC 47 ms
10,388 KB
testcase_12 AC 57 ms
11,328 KB
testcase_13 AC 43 ms
10,020 KB
testcase_14 AC 17 ms
8,036 KB
testcase_15 AC 54 ms
10,972 KB
testcase_16 AC 59 ms
11,624 KB
testcase_17 AC 68 ms
11,968 KB
testcase_18 AC 69 ms
12,044 KB
testcase_19 AC 61 ms
11,556 KB
testcase_20 AC 73 ms
15,008 KB
testcase_21 AC 85 ms
14,928 KB
testcase_22 AC 85 ms
14,904 KB
testcase_23 AC 15 ms
7,860 KB
testcase_24 AC 15 ms
7,820 KB
testcase_25 AC 16 ms
7,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S=list(input())
C=[]
if S[0]=="c":
    C.append(1)
else:
    C.append(0)

for i in range(1,len(S)):
    if S[i]=="c":
        C.append(C[-1]+1)
    else:
        C.append(C[-1])
        
s=S[::-1]
W=[]
if s[0]=="w":
    W.append(1)
else:
    W.append(0)

for i in range(1,len(S)):
    if s[i]=="w":
        W.append(W[-1]+1)
    else:
        W.append(W[-1])
W=W[::-1]
#print(S)
#print(C)
#print(W)
ans=0
for i in range(1,len(S)-1):
    if S[i]=="w":
        ans+=C[i]*(W[i]-1)
print(ans)
0