結果

問題 No.346 チワワ数え上げ問題
ユーザー soupesuteakasoupesuteaka
提出日時 2016-03-04 18:45:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 367 bytes
コンパイル時間 426 ms
コンパイル使用メモリ 11,912 KB
実行使用メモリ 14,012 KB
最終ジャッジ日時 2023-10-24 19:49:26
合計ジャッジ時間 2,690 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,020 KB
testcase_01 AC 27 ms
10,020 KB
testcase_02 AC 26 ms
10,020 KB
testcase_03 AC 26 ms
10,020 KB
testcase_04 AC 27 ms
10,020 KB
testcase_05 AC 28 ms
10,020 KB
testcase_06 AC 27 ms
10,020 KB
testcase_07 AC 29 ms
10,020 KB
testcase_08 AC 27 ms
10,020 KB
testcase_09 AC 27 ms
10,020 KB
testcase_10 AC 77 ms
13,788 KB
testcase_11 AC 58 ms
12,248 KB
testcase_12 AC 68 ms
13,056 KB
testcase_13 AC 54 ms
11,916 KB
testcase_14 AC 29 ms
10,048 KB
testcase_15 AC 68 ms
12,596 KB
testcase_16 AC 72 ms
13,216 KB
testcase_17 AC 79 ms
13,776 KB
testcase_18 AC 77 ms
13,784 KB
testcase_19 AC 73 ms
13,236 KB
testcase_20 AC 95 ms
10,892 KB
testcase_21 AC 96 ms
14,012 KB
testcase_22 AC 93 ms
14,012 KB
testcase_23 AC 27 ms
10,020 KB
testcase_24 AC 27 ms
10,020 KB
testcase_25 AC 27 ms
10,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#coding: UTF-8

import sys
from math import log
from collections import deque
from functools import reduce

### defs ###

### main ###
S = sys.stdin.readline().strip('\r\n')
sz = len(S)
wc = [0]*sz
for i in range(sz-1,-1,-1):
	if (S[i]=="w"):
		wc[i]+=1
	if (i < sz-1):
		wc[i]+=wc[i+1]
ans=0
for i in range(sz):
	if(S[i]=='c'):
		x=wc[i]
		ans+=x*(x-1)//2
print(ans)
0