結果
問題 | No.464 PPAP |
ユーザー |
![]() |
提出日時 | 2016-12-15 22:43:22 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 316 ms / 2,000 ms |
コード長 | 851 bytes |
コンパイル時間 | 1,264 ms |
コンパイル使用メモリ | 159,256 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-30 08:49:36 |
合計ジャッジ時間 | 4,548 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:25:6: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 25 | scanf("%s",s);n=strlen(s); | ~~~~~^~~~~~~~
ソースコード
#include <bits/stdc++.h>using namespace std;#define REP(i,n) for(int i=0;i<(n);i++)#define FOR(i,a,b) for(int i=(a);i<(b);i++)#define FORR(i,a,b) for(int i=(b)-1;i>=(a);i--)typedef long long ll;typedef pair<int,int> pii;typedef vector<int> vi;const ll MOD = 1000000009;#define ADD(a,b) a=((a)+(b))%MOD#define SUB(a,b) a=((a)-(b)%MOD+MOD)%MODint n;char s[12525];ll a[12525];ll b[12525];ll base=10007;ll bpow[12525];bool pal(int l,int r){ll as = a[r]; SUB(as,a[l]*bpow[r-l]);ll bs = b[l]; SUB(bs,b[r]*bpow[r-l]);return as==bs;}int main(){scanf("%s",s);n=strlen(s);REP(i,n)a[i+1]=(a[i]*base+s[i])%MOD;FORR(i,0,n)b[i]=(b[i+1]*base+s[i])%MOD;bpow[0]=1;REP(i,n)bpow[i+1]=bpow[i]*base%MOD;ll ans=0;FOR(i,2,n-2+1){ll x=0,y=0;FOR(j,1,i)x+=pal(0,j)*pal(j,i);FOR(j,i+1,n)y+=pal(j,n);ans += x*y;}cout<<ans<<endl;return 0;}