結果
問題 | No.599 回文かい |
ユーザー |
![]() |
提出日時 | 2018-01-13 15:25:50 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 31 ms / 4,000 ms |
コード長 | 511 bytes |
コンパイル時間 | 174 ms |
コンパイル使用メモリ | 23,552 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-24 00:24:12 |
合計ジャッジ時間 | 1,187 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 6 | scanf("%s", S+1); | ~~~~~^~~~~~~~~~~
ソースコード
#include <stdio.h> int main() { char S[10010]; scanf("%s", S+1); int l = 0; while (S[l+1]) l++; int n = l / 2; const int mod = 1000000007; int d[5005] ={ 1, }; for (int u=2;u<=2*n;u++){ int as = u / 2, ae = (u + 1) / 2; int bs = l + 1 - ae, be = l + 1 - as; while (1 <= as && ae <= n && S[as] == S[bs] && S[ae] == S[be]){ d[ae] = (d[ae] + d[as-1]) % mod; as--; ae++; bs--; be++; } } int ans = 0; for (int i=0;i<=n;i++) ans = (ans + d[i]) % mod; printf("%d\n", ans); return 0; }