結果
| 問題 |
No.346 チワワ数え上げ問題
|
| コンテスト | |
| ユーザー |
めうめう🎒
|
| 提出日時 | 2016-10-21 00:58:12 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 16 ms / 2,000 ms |
| コード長 | 893 bytes |
| コンパイル時間 | 663 ms |
| コンパイル使用メモリ | 73,360 KB |
| 実行使用メモリ | 13,816 KB |
| 最終ジャッジ日時 | 2024-11-23 15:58:25 |
| 合計ジャッジ時間 | 2,053 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)
string str;
ll memo[100010][5] = {};
ll dp(int now, int check){
ll count = 0;
if(check == 3) return 1;
if(now == str.size()) return 0;
if(memo[now][check] != INFLL) return memo[now][check];
if(check == 0){
if(str[now] == 'c'){
count += dp(now + 1, check + 1);
}
}else if(check == 1 || check == 2){
if(str[now] == 'w'){
count += dp(now + 1, check + 1);
}
}
count += dp(now + 1,check);
return memo[now][check] = count;
}
int main() {
for(int i = 0;i < 100010;i++){
for(int j = 0;j < 5;j++){
memo[i][j] = INFLL;
}
}
cin >> str;
cout << dp(0, 0) << endl;
return 0;
}
めうめう🎒