UVA11584 划分成回文串 Partitioning by Palindrom

Jinnie

显然的线性dp

预处理谁是回文串就可以了

#include
#include
#include
#include
#include
using namespace std;
int all[1005][1005];
string s;
int t;
int l;
int f[100001];
char ss[10001];
void che(int x){
    int ll=x;
    int r=x;
    while(ll>=1&&r<=l){
        if(ss[ll]==ss[r]){
            all[ll][r]=1;
        }else{
            break;
        }
        ll--;
        r++;
    }
    ll=x;
    r=x+1;
    while(ll>0&&r<=l){
        if(ss[ll]==ss[r]){
            all[ll][r]=1;
        }else{
            break;
        }
        ll--;
        r++;
    }
}
int main(){
     scanf("%d",&t);
    while(t--){
        cin>>s;
        l=s.length();
        for(int i=1;i<=l;++i){
            ss[i]=s[i-1];
        }
        memset(all,0,sizeof(all));
        memset(f,0x7f,sizeof(f));
        for(int i=1;i<=l;++i){
            che(i);
        }
        f[0]=0;
        for(int i=1;i<=l;++i){
            for(int j=0;j
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇
Theme Argon By solstice23