結果

問題 No.1702 count good string
ユーザー Drice27149Drice27149
提出日時 2021-10-08 22:32:58
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 880 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 32,904 KB
実行使用メモリ 10,932 KB
最終ジャッジ日時 2023-09-30 11:26:03
合計ジャッジ時間 2,399 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 13 ms
10,820 KB
testcase_14 AC 12 ms
10,884 KB
testcase_15 AC 12 ms
10,864 KB
testcase_16 AC 12 ms
10,856 KB
testcase_17 AC 13 ms
10,896 KB
testcase_18 AC 12 ms
10,896 KB
testcase_19 AC 12 ms
10,816 KB
testcase_20 AC 12 ms
10,928 KB
testcase_21 AC 12 ms
10,892 KB
testcase_22 AC 12 ms
10,932 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 15 ms
10,844 KB
testcase_34 AC 15 ms
10,860 KB
testcase_35 AC 15 ms
10,820 KB
testcase_36 AC 15 ms
10,916 KB
testcase_37 AC 15 ms
10,800 KB
testcase_38 AC 15 ms
10,888 KB
testcase_39 AC 15 ms
10,860 KB
testcase_40 AC 15 ms
10,848 KB
testcase_41 AC 15 ms
10,888 KB
testcase_42 AC 15 ms
10,928 KB
testcase_43 AC 12 ms
10,800 KB
testcase_44 AC 11 ms
10,904 KB
testcase_45 AC 1 ms
4,376 KB
testcase_46 AC 1 ms
4,380 KB
testcase_47 AC 1 ms
4,380 KB
testcase_48 AC 2 ms
4,380 KB
testcase_49 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
const int mod = 1e9+7;
char s[100005];
int f[100005][10][2];
// f[i][j][k]: i chac, now len is j, used/not
int rnk[28];

int main(){
	int n;
	scanf("%d%s",&n,s+1);
	f[0][0][0] = 1;
	int len = 9;
	char a[] = "yukicoder";
	for(int i = 0; i < 26; i++){
		char cur = 'a' + i;
		rnk[i] = -1;
		for(int j = 0; j < 9; j++){
			if(cur == a[j]) rnk[i] = j+1;
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= len; j++){
			for(int k = 0; k < 2; k++){
				f[i][j][k] = f[i-1][j][k];
				if(k && s[i]=='?' && j) f[i][j][k] = (f[i][j][k] + f[i-1][j-1][0])%mod;
				if(s[i]!='?'){
					int cur = s[i]-'a';
					if(rnk[cur]!=-1){
						int jj = rnk[cur];
						if(jj == j) f[i][j][k] = (f[i][j][k] + f[i-1][j-1][k])%mod;
					}
				}
				//printf("f[%d][%d][%d] = %lld\n",i,j,k,f[i][j][k]);
			}
			
		}
	}
	printf("%d\n",(f[n][9][0] + f[n][9][1])%mod);
	return 0;
}
0