結果

問題 No.346 チワワ数え上げ問題
ユーザー nksk38nksk38
提出日時 2017-06-29 22:01:29
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 774 bytes
コンパイル時間 685 ms
コンパイル使用メモリ 74,148 KB
実行使用メモリ 71,136 KB
最終ジャッジ日時 2024-04-15 04:57:09
合計ジャッジ時間 6,975 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
66,944 KB
testcase_01 AC 8 ms
32,028 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 4 ms
11,568 KB
testcase_04 AC 15 ms
60,704 KB
testcase_05 AC 3 ms
6,940 KB
testcase_06 AC 13 ms
52,688 KB
testcase_07 AC 10 ms
38,372 KB
testcase_08 AC 12 ms
48,608 KB
testcase_09 AC 16 ms
71,136 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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[10010][10010];

void comb_table(int N) {
	for (int i = 0; i <= N; i++) {
		for (int 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());

	int w = 0;
	ll ans = 0;
	for (int 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;
}
0