結果
問題 | No.599 回文かい |
ユーザー | 夕叢霧香(ゆうむらきりか) |
提出日時 | 2017-11-24 23:02:07 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,082 bytes |
コンパイル時間 | 2,052 ms |
コンパイル使用メモリ | 73,704 KB |
実行使用メモリ | 57,876 KB |
最終ジャッジ日時 | 2023-08-18 05:06:43 |
合計ジャッジ時間 | 6,810 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 119 ms
55,708 KB |
testcase_01 | AC | 119 ms
56,236 KB |
testcase_02 | AC | 119 ms
55,852 KB |
testcase_03 | AC | 119 ms
55,664 KB |
testcase_04 | AC | 124 ms
56,192 KB |
testcase_05 | WA | - |
testcase_06 | AC | 128 ms
55,900 KB |
testcase_07 | AC | 128 ms
55,664 KB |
testcase_08 | AC | 125 ms
56,008 KB |
testcase_09 | WA | - |
testcase_10 | AC | 202 ms
55,908 KB |
testcase_11 | AC | 180 ms
56,056 KB |
testcase_12 | AC | 210 ms
55,816 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 121 ms
56,192 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
evil_0.txt | WA | - |
ソースコード
import java.util.*; class Main { static final long MOD=1000000007; static final long P=1000000009; static long[]h,dp,p; static final long b=31; static long c(int x,int y){ long t=h[y]; t+=h[x]*(P-p[y-x])%P; return t%P; } public static void main(String[] args) { Scanner scan = new Scanner(System.in); String s=scan.next(); int n=s.length(); int[]a=new int[n]; for(int i=0;i<n;++i)a[i]=s.charAt(i)-'a'; h=new long[n+1]; p=new long[n+1]; for(int i=0;i<n;++i) h[i+1]=(b*h[i]+a[i])%P; p[0]=1; for(int i=0;i<n;++i) p[i+1]=p[i]*b%P; dp=new long[n+1]; dp[0]=1; for(int i=1;i<=n/2;++i){ long t=0; for(int j=0;j<=i;++j){ if(c(j,i)==c(n-i,n-j))t=(t+dp[j])%P; } dp[i]=t; } long t=0; for(int i=0;i<=n/2;++i) t=(t+dp[i])%P; //System.err.println(Arrays.toString(dp)); System.out.println(t); } }