結果

問題 No.464 PPAP
ユーザー rickythetarickytheta
提出日時 2016-12-15 22:43:22
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 215 ms / 2,000 ms
コード長 851 bytes
コンパイル時間 1,250 ms
コンパイル使用メモリ 146,096 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-20 07:55:10
合計ジャッジ時間 4,018 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 10 ms
4,380 KB
testcase_08 AC 10 ms
4,384 KB
testcase_09 AC 10 ms
4,380 KB
testcase_10 AC 214 ms
4,380 KB
testcase_11 AC 138 ms
4,376 KB
testcase_12 AC 215 ms
4,380 KB
testcase_13 AC 215 ms
4,380 KB
testcase_14 AC 215 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 214 ms
4,384 KB
testcase_24 AC 215 ms
4,380 KB
testcase_25 AC 214 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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)%MOD

int 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;
}
0