結果

問題 No.346 チワワ数え上げ問題
ユーザー aaaaaaiu
提出日時 2019-08-14 23:07:41
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 377 bytes
コンパイル時間 1,839 ms
コンパイル使用メモリ 193,160 KB
最終ジャッジ日時 2025-01-07 11:49:52
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    string s;
    cin>>s;
    int n=s.size();
    ll 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;
}
0