結果

問題 No.2204 Palindrome Splitting (No Rearrangement ver.)
ユーザー FplusFplusFFplusFplusF
提出日時 2023-07-31 22:23:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,335 bytes
コンパイル時間 2,615 ms
コンパイル使用メモリ 204,780 KB
実行使用メモリ 101,280 KB
最終ジャッジ日時 2024-04-18 21:52:46
合計ジャッジ時間 9,690 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,752 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 61 ms
7,424 KB
testcase_04 AC 17 ms
5,376 KB
testcase_05 AC 11 ms
5,376 KB
testcase_06 AC 108 ms
9,984 KB
testcase_07 AC 99 ms
9,472 KB
testcase_08 AC 89 ms
8,960 KB
testcase_09 AC 126 ms
9,216 KB
testcase_10 AC 127 ms
10,112 KB
testcase_11 AC 87 ms
8,960 KB
testcase_12 AC 108 ms
9,984 KB
testcase_13 AC 103 ms
10,240 KB
testcase_14 AC 122 ms
10,112 KB
testcase_15 AC 127 ms
9,600 KB
testcase_16 AC 41 ms
6,016 KB
testcase_17 AC 60 ms
6,912 KB
testcase_18 AC 107 ms
10,112 KB
testcase_19 AC 130 ms
10,112 KB
testcase_20 AC 115 ms
10,112 KB
testcase_21 AC 104 ms
9,984 KB
testcase_22 AC 112 ms
10,112 KB
testcase_23 AC 119 ms
9,984 KB
testcase_24 AC 151 ms
10,368 KB
testcase_25 AC 130 ms
10,112 KB
testcase_26 AC 103 ms
10,112 KB
testcase_27 AC 91 ms
7,808 KB
testcase_28 AC 123 ms
10,112 KB
testcase_29 AC 102 ms
9,984 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 TLE -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
using ld=long double;
const ll INF=(1ll<<60);
#define rep(i,n) for (ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(),v.end()
template<class T> void chmin(T &a,T b){
    if(a>b){
        a=b;
    }
}
template<class T> void chmax(T &a,T b){
    if(a<b){
        a=b;
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    ll n=s.size();
    vector<vector<bool>> dp(n,vector<bool>(n,false));
    rep(i,n) dp[i][i]=true;
    for(ll i=n-1;0<=i;i--){
        for(ll j=i;j<n;j++){
            if(i==j) dp[i][j]=true;
            else if(i+1==j){
                if(s[i]==s[j]) dp[i][j]=true;
            }else{
                if(s[i]==s[j]&&dp[i+1][j-1]) dp[i][j]=true;
            }
        }
    }
    vector<vector<ll>> v(n);
    rep(i,n){
        rep(j,n){
            if(dp[i][j]) v[i].push_back(j);
        }
    }
    vector<vector<bool>> dp2(n+1,vector<bool>(n+1,false));
    dp2[0][n]=true;
    rep(i,n){
        rep(j,n+1){
            if(!dp2[i][j]) continue;
            for(auto &k:v[i]){
                dp2[k+1][min(j,k-i+1)]=true;
            }
        }
    }
    ll ans=1;
    rep(i,n+1){
        if(dp2[n][i]) chmax(ans,i);
    }
    cout << ans << '\n';
}
0