結果

問題 No.1702 count good string
ユーザー tnakao0123tnakao0123
提出日時 2021-10-09 02:06:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 921 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 33,664 KB
実行使用メモリ 11,776 KB
最終ジャッジ日時 2024-04-26 17:06:28
合計ジャッジ時間 2,440 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 19 ms
11,648 KB
testcase_14 AC 19 ms
11,648 KB
testcase_15 AC 19 ms
11,648 KB
testcase_16 AC 20 ms
11,648 KB
testcase_17 AC 20 ms
11,776 KB
testcase_18 AC 19 ms
11,648 KB
testcase_19 AC 19 ms
11,776 KB
testcase_20 AC 20 ms
11,648 KB
testcase_21 AC 19 ms
11,648 KB
testcase_22 AC 19 ms
11,648 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 18 ms
11,648 KB
testcase_34 AC 18 ms
11,520 KB
testcase_35 AC 17 ms
11,648 KB
testcase_36 AC 18 ms
11,776 KB
testcase_37 AC 17 ms
11,648 KB
testcase_38 AC 18 ms
11,648 KB
testcase_39 AC 18 ms
11,776 KB
testcase_40 AC 16 ms
11,648 KB
testcase_41 AC 17 ms
11,648 KB
testcase_42 AC 18 ms
11,776 KB
testcase_43 AC 15 ms
11,648 KB
testcase_44 AC 14 ms
11,648 KB
testcase_45 AC 2 ms
5,376 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 AC 2 ms
5,376 KB
testcase_48 AC 2 ms
5,376 KB
testcase_49 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 1702.cc:  No.1702 count good string - yukicoder
 */

#include<cstdio>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int L = 9;
const char t[] = "yukicoder";
const int MOD = 1000000007;

/* typedef */

typedef long long ll;

/* global variables */

char s[MAX_N + 4];
int dp[MAX_N + 1][L + 1][2];

/* subroutines */

inline void addmod(int &a, int b) { a = (a + b) % MOD; }

/* main */

int main() {
  int n;
  scanf("%d%s", &n, s);

  dp[0][0][0] = 1;
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= L; j++)
      for (int k = 0; k < 2; k++)
	if (dp[i][j][k] > 0) {
	  addmod(dp[i + 1][j][k], dp[i][j][k]);
	  if (j < L) {
	    if (s[i] == t[j])
	      addmod(dp[i + 1][j + 1][k], dp[i][j][k]);
	    else if (s[i] == '?' && k == 0)
	      addmod(dp[i + 1][j + 1][1], dp[i][j][0]);
	  }
	}

  printf("%d\n", (dp[n][L][0] + dp[n][L][1]) % MOD);
  return 0;
}
0