結果
問題 |
No.346 チワワ数え上げ問題
|
ユーザー |
|
提出日時 | 2017-06-29 22:01:29 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 774 bytes |
コンパイル時間 | 732 ms |
コンパイル使用メモリ | 74,144 KB |
実行使用メモリ | 10,496 KB |
最終ジャッジ日時 | 2024-10-04 16:51:40 |
合計ジャッジ時間 | 6,761 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | AC * 10 TLE * 1 -- * 12 |
ソースコード
#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; }