結果
| 問題 | 
                            No.346 チワワ数え上げ問題
                             | 
                    
| コンテスト | |
| ユーザー | 
                             yn
                         | 
                    
| 提出日時 | 2016-02-26 23:53:48 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 535 bytes | 
| コンパイル時間 | 246 ms | 
| コンパイル使用メモリ | 12,544 KB | 
| 実行使用メモリ | 19,872 KB | 
| 最終ジャッジ日時 | 2024-09-23 03:16:25 | 
| 合計ジャッジ時間 | 4,200 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | -- * 3 | 
| other | AC * 10 TLE * 1 -- * 12 | 
ソースコード
import math
S = list(input())
c = [0] * len(S)
w = [0] * len(S)
ans = 0
for i in range(len(S)):
    if S[i] == "c":
        c[i] = 1
    if S[i] == "w":
        w[i] = 1
c_count = c.count(1)
c_index_bef = 0
for i in range(c_count):
    flag = 0
    w_count = 0
    c_index_cur = c.index(1)
    for j in range(c_index_bef, c_index_cur+1):
        c[j] = 0
        w[j] = 0
    w_count = w.count(1)
    if w_count < 2:
        break
    ans += (math.factorial(w_count)//(math.factorial(w_count-2) * math.factorial(2)))
print(ans)
            
            
            
        
            
yn