結果

問題 No.1702 count good string
ユーザー kotatsugamekotatsugame
提出日時 2021-10-08 22:02:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 614 bytes
コンパイル時間 562 ms
コンパイル使用メモリ 68,256 KB
実行使用メモリ 14,052 KB
最終ジャッジ日時 2023-09-30 10:11:54
合計ジャッジ時間 2,790 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
13,620 KB
testcase_01 AC 6 ms
13,784 KB
testcase_02 AC 5 ms
13,920 KB
testcase_03 AC 5 ms
13,744 KB
testcase_04 AC 5 ms
13,624 KB
testcase_05 AC 5 ms
13,588 KB
testcase_06 AC 5 ms
13,680 KB
testcase_07 AC 5 ms
13,632 KB
testcase_08 AC 5 ms
13,700 KB
testcase_09 AC 6 ms
13,596 KB
testcase_10 AC 6 ms
13,916 KB
testcase_11 AC 5 ms
13,636 KB
testcase_12 AC 5 ms
13,740 KB
testcase_13 AC 15 ms
13,820 KB
testcase_14 AC 16 ms
13,772 KB
testcase_15 AC 16 ms
13,804 KB
testcase_16 AC 15 ms
14,052 KB
testcase_17 AC 16 ms
13,724 KB
testcase_18 AC 15 ms
13,808 KB
testcase_19 AC 15 ms
13,772 KB
testcase_20 AC 16 ms
13,732 KB
testcase_21 AC 16 ms
13,868 KB
testcase_22 AC 16 ms
13,732 KB
testcase_23 AC 5 ms
13,592 KB
testcase_24 AC 6 ms
13,656 KB
testcase_25 AC 5 ms
13,756 KB
testcase_26 AC 6 ms
13,688 KB
testcase_27 AC 5 ms
13,600 KB
testcase_28 AC 5 ms
13,624 KB
testcase_29 AC 5 ms
13,640 KB
testcase_30 AC 6 ms
13,624 KB
testcase_31 AC 6 ms
13,640 KB
testcase_32 AC 6 ms
13,680 KB
testcase_33 AC 15 ms
13,884 KB
testcase_34 AC 15 ms
13,736 KB
testcase_35 AC 16 ms
13,768 KB
testcase_36 AC 15 ms
13,804 KB
testcase_37 AC 15 ms
13,736 KB
testcase_38 AC 15 ms
13,772 KB
testcase_39 AC 15 ms
13,820 KB
testcase_40 AC 15 ms
13,756 KB
testcase_41 AC 16 ms
13,808 KB
testcase_42 AC 15 ms
13,752 KB
testcase_43 AC 15 ms
13,740 KB
testcase_44 AC 15 ms
13,732 KB
testcase_45 AC 6 ms
13,672 KB
testcase_46 AC 5 ms
13,636 KB
testcase_47 AC 6 ms
13,688 KB
testcase_48 AC 5 ms
13,788 KB
testcase_49 AC 5 ms
13,876 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:9:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    9 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<atcoder/modint>
using namespace std;
using mint=atcoder::modint1000000007;
int N;
string S;
string T="yukicoder";
mint L[10][1<<17],R[10][1<<17];
main()
{
	cin>>N>>S;
	L[0][0]=1;
	for(int i=0;i<N;i++)
	{
		for(int j=9;j>=0;j--)
		{
			L[j][i+1]=L[j][i];
			if(j<9&&S[i]==T[j])L[j+1][i+1]+=L[j][i];
		}
	}
	R[9][N]=1;
	for(int i=N;i--;)
	{
		for(int j=0;j<=9;j++)
		{
			R[j][i]=R[j][i+1];
			if(j>0&&S[i]==T[j-1])R[j-1][i]+=R[j][i+1];
		}
	}
	mint ans=L[9][N];
	for(int i=0;i<N;i++)if(S[i]=='?')
	{
		for(int l=0;l<9;l++)
		{
			ans+=L[l][i]*R[l+1][i];
		}
	}
	cout<<ans.val()<<endl;
}
0