結果

問題 No.346 チワワ数え上げ問題
ユーザー airisairis
提出日時 2016-02-26 23:45:47
言語 Python2
(2.7.18)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 241 bytes
コンパイル時間 783 ms
コンパイル使用メモリ 6,700 KB
実行使用メモリ 9,260 KB
最終ジャッジ日時 2023-07-23 03:59:55
合計ジャッジ時間 2,791 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
5,932 KB
testcase_01 AC 11 ms
5,876 KB
testcase_02 AC 11 ms
5,932 KB
testcase_03 AC 11 ms
5,904 KB
testcase_04 AC 10 ms
6,124 KB
testcase_05 AC 11 ms
5,932 KB
testcase_06 AC 11 ms
6,092 KB
testcase_07 AC 11 ms
5,824 KB
testcase_08 AC 10 ms
5,900 KB
testcase_09 AC 10 ms
5,824 KB
testcase_10 AC 47 ms
8,848 KB
testcase_11 AC 32 ms
7,548 KB
testcase_12 AC 39 ms
8,136 KB
testcase_13 AC 29 ms
7,424 KB
testcase_14 AC 12 ms
5,924 KB
testcase_15 AC 36 ms
7,880 KB
testcase_16 AC 40 ms
8,232 KB
testcase_17 AC 46 ms
8,848 KB
testcase_18 AC 47 ms
8,832 KB
testcase_19 AC 41 ms
8,312 KB
testcase_20 AC 70 ms
6,680 KB
testcase_21 AC 62 ms
8,784 KB
testcase_22 AC 62 ms
9,260 KB
testcase_23 AC 11 ms
5,996 KB
testcase_24 AC 10 ms
5,892 KB
testcase_25 AC 10 ms
5,936 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