結果

問題 No.346 チワワ数え上げ問題
コンテスト
ユーザー nebukuro09
提出日時 2016-10-23 13:40:04
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 415 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 285 ms
コンパイル使用メモリ 77,812 KB
最終ジャッジ日時 2025-12-03 22:20:30
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

S = raw_input()
c_index = [i for i in xrange(len(S)) if S[i] == 'c']
w_index = [i for i in xrange(len(S)) if S[i] == 'w']
if len(c_index) == 0 or len(w_index) == 0:
    print 0
    exit()
wp = 0
ans = 0
for c in c_index:
    if wp >= len(w_index):
        break
    while w_index[wp] < c:
        wp += 1
        if wp >= len(w_index):
            break
    ans += (len(w_index)-wp)*(len(w_index)-wp-1)/2
print ans
0