結果

問題 No.346 チワワ数え上げ問題
ユーザー nebukuro09
提出日時 2016-10-23 13:38:59
言語 Python2
(2.7.18)
結果
RE  
実行時間 -
コード長 374 bytes
コンパイル時間 442 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 9,600 KB
最終ジャッジ日時 2024-11-24 01:54:57
合計ジャッジ時間 2,265 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 RE * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

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