結果

問題 No.346 チワワ数え上げ問題
ユーザー kroton
提出日時 2016-02-27 07:15:27
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 398 bytes
コンパイル時間 519 ms
コンパイル使用メモリ 61,276 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-24 11:17:48
合計ジャッジ時間 1,435 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

ll solve(const string& S, const string& target) {
	vector<ll> dp(target.size() + 1, 0);
	dp[0] = 1;
	for(char c : S){
		for(int i=target.size()-1;i>=0;--i){
			if(c == target[i]){
				dp[i+1] += dp[i];
			}
		}
	}
	return dp.back();
}

int main(){
	string S;
	cin >> S;
	cout << solve(S, "cww") << endl;
	return 0;
}
0