結果

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

ソースコード

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:
    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