結果
問題 | No.1702 count good string |
ユーザー |
|
提出日時 | 2021-10-08 22:02:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 17 ms / 2,000 ms |
コード長 | 614 bytes |
コンパイル時間 | 923 ms |
コンパイル使用メモリ | 68,396 KB |
実行使用メモリ | 13,952 KB |
最終ジャッジ日時 | 2024-07-23 04:17:27 |
合計ジャッジ時間 | 2,771 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 47 |
コンパイルメッセージ
main.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 9 | main() | ^~~~
ソースコード
#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;}