結果
| 問題 | 
                            No.346 チワワ数え上げ問題
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2019-08-14 23:06:43 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 378 bytes | 
| コンパイル時間 | 2,318 ms | 
| コンパイル使用メモリ | 192,948 KB | 
| 最終ジャッジ日時 | 2025-01-07 11:49:43 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 21 WA * 2 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    string s;
    cin>>s;
    int n=s.size();
    int W[n+1]{};
    for (int i=n-1;i>=0;i--) {
        W[i]=W[i+1]+(s[i]=='w');
    }
    ll ans=0;
    for (int i=0;i<n;i++) {
        if (s[i]=='c'&&W[i]>=2) {
            ans+=W[i]*(W[i]-1)/2;
        }
    }
    cout<<ans<<endl;
    return 0;
}