結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,016 KB
testcase_01 RE -
testcase_02 AC 11 ms
6,144 KB
testcase_03 AC 11 ms
6,016 KB
testcase_04 AC 12 ms
6,144 KB
testcase_05 AC 12 ms
6,016 KB
testcase_06 AC 12 ms
6,144 KB
testcase_07 RE -
testcase_08 AC 11 ms
6,144 KB
testcase_09 AC 11 ms
6,016 KB
testcase_10 AC 34 ms
6,656 KB
testcase_11 AC 25 ms
6,400 KB
testcase_12 AC 29 ms
6,528 KB
testcase_13 AC 24 ms
6,528 KB
testcase_14 AC 11 ms
6,272 KB
testcase_15 AC 28 ms
6,400 KB
testcase_16 AC 31 ms
6,400 KB
testcase_17 AC 34 ms
6,528 KB
testcase_18 AC 34 ms
6,528 KB
testcase_19 RE -
testcase_20 AC 38 ms
9,472 KB
testcase_21 AC 70 ms
9,472 KB
testcase_22 AC 70 ms
9,472 KB
testcase_23 AC 11 ms
6,272 KB
testcase_24 AC 11 ms
6,144 KB
testcase_25 AC 11 ms
6,144 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:
    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