結果

問題 No.2204 Palindrome Splitting (No Rearrangement ver.)
ユーザー たたき@競プロ
提出日時 2023-07-13 07:36:13
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 160 ms / 2,000 ms
コード長 753 bytes
コンパイル時間 2,988 ms
コンパイル使用メモリ 250,552 KB
実行使用メモリ 101,248 KB
最終ジャッジ日時 2024-09-14 19:21:09
合計ジャッジ時間 6,375 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
 
using ll=long long;
using pp=pair<int,int>;
#define sr string 
#define vc vector
#define db double
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define pque priority_queue
#define bpc(a) __builtin_popcount(a)
int main(){
	sr s;cin>>s;
	int n=s.size();
	vc ok(n,vc<int>(n,false));
	rep(i,n){
		int l=i,r=i;
		while(l>=0&&r<n&&s[l]==s[r]){
			ok[l][r]=true;
			l--,r++;
		}
	}
	rep(i,n-1){
		int l=i,r=i+1;
		while(l>=0&&r<n&&s[l]==s[r]){
			ok[l][r]=true;
			l--,r++;
		}
	}
	vc<int>dp(n+1,0);
	dp[0]=1e9;
	rep(i,n)for(int j=i+1;j<=n;j++)if(ok[i][j-1]){
		int d=j-i;
		dp[j]=max(dp[j],min(dp[i],d));
	}
	cout<<dp[n];
}
	
0