結果

問題 No.464 PPAP
ユーザー vjudge1
提出日時 2025-07-25 20:49:03
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 165 ms / 2,000 ms
コード長 833 bytes
コンパイル時間 1,283 ms
コンパイル使用メモリ 163,984 KB
実行使用メモリ 27,916 KB
最終ジャッジ日時 2025-07-25 20:49:07
合計ジャッジ時間 3,266 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=5010;
const int mod=1e9+7;
int n;
int ans;
string s;
bool fl[N][N];
int f[N];
signed main(){
	// ios::sync_with_stdio(0);
	// cin.tie(0);
	// cout.tie(0);
	// freopen("par.in","r",stdin);
	// freopen("par.out","w",stdout);
	cin>>s;
	n=s.size();
	s=" "+s;
	for(int i=1;i<=n;i++){
		for(int l=i,r=i;l>=1&&r<=n;l--,r++){
			if(s[l]!=s[r])break;
			fl[l][r]=1;
		}
	}
	for(int i=1;i<n;i++){
		for(int l=i,r=i+1;l>=1&&r<=n;l--,r++){
			if(s[l]!=s[r])break;
			fl[l][r]=1;
		}
	}
	for(int i=2;i<=n;i++){
		for(int j=i;j<=n;j++){
			if(!fl[i][j])continue;
			if(!fl[1][i-1])continue;
			f[j]++;
		}
	}
	for(int i=2;i<n;i++){
		for(int j=i;j<n;j++){
			if(!f[i-1])continue;
			if(!fl[j+1][n])continue;
			ans+=f[i-1];
		}
	}
	cout<<ans<<"\n";
	return 0;
}
/*

*/
0