結果

問題 No.346 チワワ数え上げ問題
ユーザー airisairis
提出日時 2016-02-26 23:45:47
言語 Python2
(2.7.18)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 241 bytes
コンパイル時間 811 ms
コンパイル使用メモリ 7,132 KB
実行使用メモリ 9,680 KB
最終ジャッジ日時 2023-10-24 10:45:40
合計ジャッジ時間 2,943 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,444 KB
testcase_01 AC 11 ms
6,444 KB
testcase_02 AC 11 ms
6,444 KB
testcase_03 AC 11 ms
6,444 KB
testcase_04 AC 11 ms
6,444 KB
testcase_05 AC 11 ms
6,444 KB
testcase_06 AC 12 ms
6,444 KB
testcase_07 AC 12 ms
6,444 KB
testcase_08 AC 12 ms
6,444 KB
testcase_09 AC 11 ms
6,444 KB
testcase_10 AC 53 ms
9,416 KB
testcase_11 AC 36 ms
8,116 KB
testcase_12 AC 44 ms
8,644 KB
testcase_13 AC 34 ms
7,852 KB
testcase_14 AC 12 ms
6,468 KB
testcase_15 AC 41 ms
8,380 KB
testcase_16 AC 45 ms
8,892 KB
testcase_17 AC 53 ms
9,416 KB
testcase_18 AC 53 ms
9,416 KB
testcase_19 AC 48 ms
8,896 KB
testcase_20 AC 80 ms
7,304 KB
testcase_21 AC 69 ms
9,680 KB
testcase_22 AC 70 ms
9,680 KB
testcase_23 AC 11 ms
6,444 KB
testcase_24 AC 11 ms
6,444 KB
testcase_25 AC 11 ms
6,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

s = raw_input()
sumw = [0] * (len(s) + 1)
for i in xrange(len(s)):
  sumw[i + 1] = sumw[i] + (s[i] == "w")
ans = 0
for i in xrange(len(s)):
  if s[i] != "c":
    continue
  x = sumw[len(s)] - sumw[i + 1]
  ans += x * (x - 1) / 2;
print ans

0