結果

問題 No.346 チワワ数え上げ問題
ユーザー Kmcode1Kmcode1
提出日時 2016-02-26 22:25:19
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 1,081 bytes
コンパイル時間 673 ms
コンパイル使用メモリ 91,076 KB
実行使用メモリ 11,204 KB
最終ジャッジ日時 2023-10-23 20:26:01
合計ジャッジ時間 1,566 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 8 ms
11,192 KB
testcase_11 AC 6 ms
8,980 KB
testcase_12 AC 7 ms
9,792 KB
testcase_13 AC 6 ms
8,672 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 6 ms
9,512 KB
testcase_16 AC 7 ms
9,932 KB
testcase_17 AC 8 ms
11,120 KB
testcase_18 AC 9 ms
11,164 KB
testcase_19 AC 7 ms
10,128 KB
testcase_20 AC 10 ms
11,204 KB
testcase_21 AC 8 ms
11,204 KB
testcase_22 AC 10 ms
11,204 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 1 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:68:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   68 |         scanf("%s", buf);
      |         ~~~~~^~~~~~~~~~~

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<bitset>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<ctime>
#include<complex>
#include<functional>
#include<climits>
#include<cassert>
#include<iterator>
using namespace std;

string s;


string f = "cww";


#define MAX 100002
bool use[MAX][4];
long long int dp[MAX][4];

char buf[MAX];


int n;

inline long long int dfs(int a, int b){
	if (use[a][b]){
		return dp[a][b];
	}
	if (b == 3){
		return 1;
	}
	if (a == n){
		return 0;
	}
	use[a][b] = true;
	if (f[b] == s[a]){
		dp[a][b] = dfs(a + 1, b + 1);
	}
	dp[a][b] += dfs(a + 1, b);
	return dp[a][b];
}
int main(){
	scanf("%s", buf);
	s = buf;
	n = s.size();
	long long int ans = dfs(0, 0);
	printf("%lld\n", ans);
	return 0;
}
0