結果
| 問題 | 
                            No.346 チワワ数え上げ問題
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2017-06-29 22:07:19 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 766 bytes | 
| コンパイル時間 | 784 ms | 
| コンパイル使用メモリ | 73,908 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-10-04 16:53:24 | 
| 合計ジャッジ時間 | 4,920 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 13 TLE * 10 | 
ソースコード
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#define mod 1000000007;
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pr;
string s;
ll C[100010][3];
void comb_table(ll N) {
	for (ll i = 0; i <= N; i++) {
		for (ll j = 0; j <= i; j++) {
			if (j == 0 || j == i) {
				C[i][j] = 1LL;
			}
			else {
				C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
			}
		}
	}
}
int main()
{
	cin >> s;
	comb_table(s.size());
	ll w = 0;
	ll ans = 0;
	for (ll i = s.size() - 1; i >= 0; i--) {
		if (s[i] == 'w')w++;
		if (s[i] == 'c' && w >= 2) {
			ans += C[w][2];
		}
	}
	cout << ans << endl;
	return 0;
}