結果
問題 | No.1702 count good string |
ユーザー |
![]() |
提出日時 | 2021-10-08 22:12:58 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 958 bytes |
コンパイル時間 | 2,469 ms |
コンパイル使用メモリ | 78,084 KB |
実行使用メモリ | 54,560 KB |
最終ジャッジ日時 | 2024-07-23 04:38:16 |
合計ジャッジ時間 | 7,648 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 WA * 41 |
ソースコード
import java.io.*; import java.util.*; class Main { public static void main(String args[])throws Exception { BufferedReader bu=new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb=new StringBuilder(); int n=Integer.parseInt(bu.readLine()); char s[]=bu.readLine().toCharArray(); HashMap<Character,Integer> mp=new HashMap<>(); String x="yukicoder"; int i,l=x.length(); for(i=0;i<l;i++) mp.put(x.charAt(i),i); mp.put('?',l); long dp[]=new long[l],M=(int)1e9+7; for(i=0;i<n;i++) if(mp.get(s[i])!=null) { int in=mp.get(s[i]); if(in==0) dp[0]=(dp[0]+1)%M; else if(in!=l) dp[in]=(dp[in]+dp[in-1])%M; else { for(int j=l-1;j>0;j--) dp[j]=(dp[j-1]+dp[j])%M; dp[0]=(dp[0]+1)%M; } } System.out.println(dp[l-1]); } }