結果
問題 |
No.1702 count good string
|
ユーザー |
![]() |
提出日時 | 2021-10-08 23:05:41 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 805 bytes |
コンパイル時間 | 962 ms |
コンパイル使用メモリ | 70,380 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-23 06:31:18 |
合計ジャッジ時間 | 2,653 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 47 |
コンパイルメッセージ
main.cpp:8:19: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] 8 | constexpr char* t="yukicoder"; | ^~~~~~~~~~~
ソースコード
#pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include<iostream> using namespace std; constexpr unsigned int mod=1000000007; unsigned int dp[2][10]; constexpr char* t="yukicoder"; string s; int main(){ cin.tie(0); ios::sync_with_stdio(false); cin>>s>>s; dp[0][0]=1; for(auto x:s){ if(x=='?'){ for(unsigned int j=0;j<9;++j){ dp[1][j+1]+=dp[0][j]; if(dp[1][j+1]>=mod)dp[1][j+1]-=mod; } }else{ for(unsigned int j=0;j<9;++j){ if(x==t[j]){ dp[0][j+1]+=dp[0][j]; if(dp[0][j+1]>=mod)dp[0][j+1]-=mod; dp[1][j+1]+=dp[1][j]; if(dp[1][j+1]>=mod)dp[1][j+1]-=mod; } } } } unsigned int ans=dp[0][9]+dp[1][9]; if(ans>=mod)ans-=mod; cout<<ans<<'\n'; }