結果

問題 No.2204 Palindrome Splitting (No Rearrangement ver.)
ユーザー たたき@競プロたたき@競プロ
提出日時 2023-07-13 07:36:13
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 154 ms / 2,000 ms
コード長 753 bytes
コンパイル時間 2,814 ms
コンパイル使用メモリ 248,852 KB
実行使用メモリ 101,140 KB
最終ジャッジ日時 2023-10-12 21:02:36
合計ジャッジ時間 6,613 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 52 ms
60,012 KB
testcase_04 AC 14 ms
16,524 KB
testcase_05 AC 8 ms
10,500 KB
testcase_06 AC 85 ms
100,992 KB
testcase_07 AC 75 ms
90,444 KB
testcase_08 AC 69 ms
82,272 KB
testcase_09 AC 73 ms
86,304 KB
testcase_10 AC 86 ms
101,064 KB
testcase_11 AC 69 ms
82,248 KB
testcase_12 AC 84 ms
99,928 KB
testcase_13 AC 85 ms
101,024 KB
testcase_14 AC 85 ms
100,996 KB
testcase_15 AC 79 ms
93,320 KB
testcase_16 AC 34 ms
40,304 KB
testcase_17 AC 44 ms
52,356 KB
testcase_18 AC 85 ms
101,008 KB
testcase_19 AC 85 ms
101,020 KB
testcase_20 AC 86 ms
101,088 KB
testcase_21 AC 85 ms
101,004 KB
testcase_22 AC 85 ms
101,012 KB
testcase_23 AC 85 ms
101,004 KB
testcase_24 AC 85 ms
101,000 KB
testcase_25 AC 86 ms
101,068 KB
testcase_26 AC 85 ms
100,980 KB
testcase_27 AC 57 ms
66,248 KB
testcase_28 AC 84 ms
101,140 KB
testcase_29 AC 85 ms
101,008 KB
testcase_30 AC 1 ms
4,356 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 154 ms
76,444 KB
testcase_33 AC 86 ms
101,068 KB
testcase_34 AC 2 ms
4,352 KB
testcase_35 AC 154 ms
76,520 KB
権限があれば一括ダウンロードができます

ソースコード

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