結果

問題 No.346 チワワ数え上げ問題
ユーザー puni_kyopropuni_kyopro
提出日時 2019-07-18 12:39:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 1,702 bytes
コンパイル時間 689 ms
コンパイル使用メモリ 80,752 KB
実行使用メモリ 6,720 KB
最終ジャッジ日時 2023-08-26 16:31:16
合計ジャッジ時間 2,452 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 8 ms
6,644 KB
testcase_11 AC 5 ms
5,260 KB
testcase_12 AC 6 ms
6,092 KB
testcase_13 AC 5 ms
5,128 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 7 ms
5,668 KB
testcase_16 AC 7 ms
6,244 KB
testcase_17 AC 8 ms
6,504 KB
testcase_18 AC 8 ms
6,644 KB
testcase_19 AC 7 ms
6,080 KB
testcase_20 AC 8 ms
6,664 KB
testcase_21 AC 8 ms
6,600 KB
testcase_22 AC 8 ms
6,720 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,384 KB
testcase_25 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };


/******************************************************************************************/

ll dp[100005][4];

int main() {

	string s;
	cin >> s;
	string cw = "cww";
	dp[0][0] = 0;

	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'c') {
			dp[i][0]++;
		}
		else if (s[i] == 'w') {
			dp[i + 1][2] += dp[i][1];
			dp[i + 1][1] += dp[i][0];
		}
		dp[i + 1][0] += dp[i][0];
		dp[i + 1][1] += dp[i][1];
		dp[i + 1][2] += dp[i][2];
	}


	cout << dp[s.size()][2] << endl;

	return 0;
}
0