結果

問題 No.346 チワワ数え上げ問題
ユーザー nebukuro09nebukuro09
提出日時 2016-10-23 13:40:04
言語 Python2
(2.7.18)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 415 bytes
コンパイル時間 55 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 9,472 KB
最終ジャッジ日時 2024-05-03 04:47:40
合計ジャッジ時間 1,658 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,272 KB
testcase_01 AC 12 ms
6,144 KB
testcase_02 AC 11 ms
6,272 KB
testcase_03 AC 11 ms
6,144 KB
testcase_04 AC 11 ms
6,272 KB
testcase_05 AC 10 ms
6,144 KB
testcase_06 AC 11 ms
6,144 KB
testcase_07 AC 11 ms
6,144 KB
testcase_08 AC 11 ms
6,016 KB
testcase_09 AC 11 ms
6,144 KB
testcase_10 AC 35 ms
6,400 KB
testcase_11 AC 25 ms
6,400 KB
testcase_12 AC 30 ms
6,528 KB
testcase_13 AC 23 ms
6,272 KB
testcase_14 AC 12 ms
6,144 KB
testcase_15 AC 28 ms
6,528 KB
testcase_16 AC 32 ms
6,528 KB
testcase_17 AC 35 ms
6,528 KB
testcase_18 AC 36 ms
6,528 KB
testcase_19 AC 35 ms
6,656 KB
testcase_20 AC 39 ms
9,344 KB
testcase_21 AC 78 ms
9,472 KB
testcase_22 AC 78 ms
9,472 KB
testcase_23 AC 11 ms
6,144 KB
testcase_24 AC 11 ms
6,144 KB
testcase_25 AC 11 ms
6,272 KB
権限があれば一括ダウンロードができます

ソースコード

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