QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#95760#5577. AlchemyUsername#AC ✓2ms3664kbC++20885b2023-04-11 20:26:572023-04-11 20:26:58

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-11 20:26:58]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:3664kb
  • [2023-04-11 20:26:57]
  • 提交

answer

#include <bits/stdc++.h>

#define el '\n'

typedef long long ll;
typedef long double ld;

#define Beevo ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

const int N = 100 + 5;

int n;
string s;
int dp[N][N][2];

int solve(int l, int r, bool ch) {
    if (l >= r)
        return 0;

    int &ret = dp[l][r][ch];

    if (~ret)
        return ret;

    ret = solve(l + 2, r - 2, 0) + 2;

    if (ch || s[l] != s[r])
        ret = min(ret, solve(l + 1, r - 1, 1) + 1);

    if (ch && s[l] != s[r] || !ch && s[l] == s[r])
        ret = min(ret, solve(l + 1, r - 1, 0));

    return ret;
}

void testCase() {
    cin >> s;

    n = s.size();

    memset(dp, -1, sizeof dp);

    cout << solve(0, n - 1, 0);
}

signed main() {
    Beevo

    int t = 1;
//    cin >> t;

    while (t--)
        testCase();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3600kb

input:

ioi

output:

0

result:

ok single line: '0'

Test #2:

score: 0
Accepted
time: 2ms
memory: 3428kb

input:

noi

output:

1

result:

ok single line: '1'

Test #3:

score: 0
Accepted
time: 2ms
memory: 3388kb

input:

ctsc

output:

1

result:

ok single line: '1'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3480kb

input:

fool

output:

2

result:

ok single line: '2'

Test #5:

score: 0
Accepted
time: 2ms
memory: 3432kb

input:

vetted

output:

2

result:

ok single line: '2'

Test #6:

score: 0
Accepted
time: 2ms
memory: 3420kb

input:

aa

output:

0

result:

ok single line: '0'

Test #7:

score: 0
Accepted
time: 2ms
memory: 3608kb

input:

ic

output:

1

result:

ok single line: '1'

Test #8:

score: 0
Accepted
time: 2ms
memory: 3492kb

input:

tlffohemdcncrfrxaqsbzcoyodvbxmhqukvfpahnakexcmacqa

output:

12

result:

ok single line: '12'

Test #9:

score: 0
Accepted
time: 2ms
memory: 3440kb

input:

qrgld

output:

1

result:

ok single line: '1'

Test #10:

score: 0
Accepted
time: 2ms
memory: 3480kb

input:

ejyfprguvwrnrsrykyrotmdjuzroohvlxqhvyeukkvmshtpczyyecpzhsqvkxueqvhlxldhofrzcjdhtotykgrsdnrnvuyrphyjy

output:

26

result:

ok single line: '26'

Test #11:

score: 0
Accepted
time: 2ms
memory: 3504kb

input:

xcpccpcy

output:

2

result:

ok single line: '2'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3440kb

input:

abpccpcp

output:

1

result:

ok single line: '1'

Test #13:

score: 0
Accepted
time: 2ms
memory: 3492kb

input:

ixpccpci

output:

2

result:

ok single line: '2'

Test #14:

score: 0
Accepted
time: 2ms
memory: 3480kb

input:

xcxccpci

output:

2

result:

ok single line: '2'

Test #15:

score: 0
Accepted
time: 2ms
memory: 3508kb

input:

xcpxcpci

output:

3

result:

ok single line: '3'

Test #16:

score: 0
Accepted
time: 2ms
memory: 3600kb

input:

ixxccpci

output:

1

result:

ok single line: '1'

Test #17:

score: 0
Accepted
time: 2ms
memory: 3504kb

input:

ixpxcpci

output:

2

result:

ok single line: '2'

Test #18:

score: 0
Accepted
time: 0ms
memory: 3492kb

input:

ixpxxycpci

output:

3

result:

ok single line: '3'

Test #19:

score: 0
Accepted
time: 0ms
memory: 3432kb

input:

yxxxyxxxxxyyxxyxxyxyyyxyxyyyyxyxxxxxxxxxxxxyyxxyxyxyyxxyyxyxxyyxxyyyyyyxxyyxxyyxxxxyyyxxxyyxyxyxxyxx

output:

19

result:

ok single line: '19'

Test #20:

score: 0
Accepted
time: 2ms
memory: 3504kb

input:

caacbbacc

output:

2

result:

ok single line: '2'

Test #21:

score: 0
Accepted
time: 2ms
memory: 3660kb

input:

xjnfkxxjfnjx

output:

2

result:

ok single line: '2'

Test #22:

score: 0
Accepted
time: 2ms
memory: 3664kb

input:

baabaaa

output:

2

result:

ok single line: '2'

Test #23:

score: 0
Accepted
time: 2ms
memory: 3496kb

input:

bbaccaabcabca

output:

3

result:

ok single line: '3'

Test #24:

score: 0
Accepted
time: 0ms
memory: 3476kb

input:

ozo

output:

0

result:

ok single line: '0'

Test #25:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

zoooo

output:

2

result:

ok single line: '2'

Test #26:

score: 0
Accepted
time: 2ms
memory: 3480kb

input:

zooooo

output:

2

result:

ok single line: '2'

Test #27:

score: 0
Accepted
time: 2ms
memory: 3492kb

input:

ccclcclllclllcllcccccclclclclccccccllllllclccclcccllclclcllcllcllccllcllclccllclcclcclclllclllclclcc

output:

16

result:

ok single line: '16'

Test #28:

score: 0
Accepted
time: 1ms
memory: 3512kb

input:

hhzhhhhzzzzhzhzzzhhzzhzzzzhzzhhzhzhhzhhhzzhzzhzzzzhzzzzhzhzhzhzzhhhhzhzzhzhhhzzzhzzhhzzhzzzzhhhzhhzz

output:

22

result:

ok single line: '22'

Test #29:

score: 0
Accepted
time: 1ms
memory: 3524kb

input:

vaaaaaaavvavvaaaaavvavavavvvvvavavvvvvavvvvaavaavavvvvavavvvvavvavvvavvvvvvvavvvavaaavavvaaaavaavvaa

output:

18

result:

ok single line: '18'

Test #30:

score: 0
Accepted
time: 2ms
memory: 3420kb

input:

pjppjjpjpjjpjppjpppjpjjjjjppjjpjppjpjpppjjjppppjpjpjjjpjpjppjpppjjpppppjpjpjjpjjjppjjjpjjjjjpjpjjppj

output:

20

result:

ok single line: '20'

Test #31:

score: 0
Accepted
time: 2ms
memory: 3484kb

input:

xxxlllxllllxlxlxllxlxlxxlxxlxxllxlxxxlxlxllxxllxllxxlxxlxxlllxxxlxxlllxxxlllllxxxxxxxlxlllxxlxlxllll

output:

20

result:

ok single line: '20'

Test #32:

score: 0
Accepted
time: 2ms
memory: 3600kb

input:

gggggvgvgggggvggvggggvvgvgvvgvggvggvgvvgvgvvvvvgvggvvgvgvvvgvvgggvvgggvgggggvggggggvvvggvggggvvgvggg

output:

17

result:

ok single line: '17'

Test #33:

score: 0
Accepted
time: 2ms
memory: 3344kb

input:

vvvbbvvbbvvbbvbvbbbbbbvbvvvbvvbbvbbvvvbbbvbvbbvbvbbvbbvvvbvbbbvbvbbbbbvbbvvvbbbbbvbvvbvvbvbbbbvbbvbb

output:

18

result:

ok single line: '18'

Test #34:

score: 0
Accepted
time: 2ms
memory: 3432kb

input:

ooooeeeeoeoeeoooeeeeeeoooeoooooeeoeoooeeoeeeoeooeooeeeooeeeeoooeeeoooeeeoooooooeoeoeeoeeoooeeooeoooe

output:

20

result:

ok single line: '20'

Test #35:

score: 0
Accepted
time: 1ms
memory: 3500kb

input:

fvfvvffvvfffvfvfffvfvfffffvvvfvfffvffvffvvvfvffvffvffvvfvfffvfvvvfvfvfvfvfvfvffvfvffvffvfvvvfvfffvfv

output:

19

result:

ok single line: '19'

Test #36:

score: 0
Accepted
time: 2ms
memory: 3428kb

input:

vvvnvnnnvnvvvnvnvvvvvnvvnnvnnvnnvvvnvnnvvvnvvnvnnnvnnnnnvvvnnvnvnnvnnvvnnvnnvnvvvvnvvnnnnvvvnnvnnnvn

output:

20

result:

ok single line: '20'

Test #37:

score: 0
Accepted
time: 2ms
memory: 3476kb

input:

vxvexexxexxvvexxeexexvvvxexxxvxeevxeevvexvevxevexevxxvvevvevexexeeexxexvxexeexvxexvevxxxxxxxeevvexev

output:

22

result:

ok single line: '22'

Test #38:

score: 0
Accepted
time: 2ms
memory: 3644kb

input:

fssfkffsfsssffffsskfssssfkffkfksfkssfsffkkfffssksskfkskkkkkkfffffkkkfkkfffffkfsssskkssfksffffffffkff

output:

21

result:

ok single line: '21'

Test #39:

score: 0
Accepted
time: 2ms
memory: 3524kb

input:

effyeyyeeyeefefyeyfffeeeffffyfyefyeyyyfefeffyefyyefyyfyfffyyfyfefefyfyeffyffeyfeefffyyeeeyfyyeffeffy

output:

22

result:

ok single line: '22'

Test #40:

score: 0
Accepted
time: 2ms
memory: 3664kb

input:

attftftaatataftfaftfftffaaafatafattffatfffattatattttffttaffaftaftafffaffatttatatftaafattttffaffttfff

output:

21

result:

ok single line: '21'

Test #41:

score: 0
Accepted
time: 0ms
memory: 3500kb

input:

dxdttddxxtdxxddxxxtdxtdtddtddttxxddddxxdxddttxdxdtttddtdxttdtdxxttdxtxxxtxxdtxxdxtxdtdtxdxttdttxxxxd

output:

21

result:

ok single line: '21'

Test #42:

score: 0
Accepted
time: 2ms
memory: 3428kb

input:

etetetextttxetteexeetttteeetxeeeexxeeettexeteteeexetxtexxxexeeetexxxttxetttxetxetetxxxeexxteteexextt

output:

25

result:

ok single line: '25'

Test #43:

score: 0
Accepted
time: 2ms
memory: 3504kb

input:

cuccddddcuccduuduccdducdcudcdccducdcccccduucdducccuuucddcdccdudddcccddudcdcdududuccdudduduucdduddddu

output:

21

result:

ok single line: '21'

Test #44:

score: 0
Accepted
time: 2ms
memory: 3600kb

input:

eeleleeljljjellejjlejjleelljllllllleljljllelejjeeelllejjjjljeeejjleljlelleejjejeleeleeljejejjjejelee

output:

23

result:

ok single line: '23'

Test #45:

score: 0
Accepted
time: 2ms
memory: 3388kb

input:

kkkvkyvvkykkkkyyyvkyyvvyyvvykvkkvvvyvyyyvykkykyyvvkvvyyyykkkyvkykvyyyvkyvkkkkkkkvvvkvvyvvkkkkkyvvkvv

output:

23

result:

ok single line: '23'

Test #46:

score: 0
Accepted
time: 0ms
memory: 3508kb

input:

fddfftftfdfffdtttdfdffddtdffdtffftdfdffftddddffdddffddtddftfttdtfdtffdftttdtdfdfdddttffftdtfddtttfft

output:

19

result:

ok single line: '19'

Test #47:

score: 0
Accepted
time: 2ms
memory: 3484kb

input:

aoaoaoaaaoaaoaoaoaooaoaoaaooaoaaooaaoooaooaooaaoaooaaaaaoooooaaoaoaoaaaoooaaaooaaaaaaooooaaaaaaaaoo

output:

21

result:

ok single line: '21'

Test #48:

score: 0
Accepted
time: 2ms
memory: 3504kb

input:

yyyyydddyyddyyydddyddddyyyyyyddydydyddyddyydyddddyyddddyyddyyydyddyddddyydyyydddddyddyydddddyyyddyy

output:

20

result:

ok single line: '20'

Test #49:

score: 0
Accepted
time: 2ms
memory: 3612kb

input:

eaeeaaaaeaaeaaaaeeeeaeaeaaaeaeeeaeaaaaaeeaaaeaaeeaaaeeaeeeeaeaeaeaeeaeeaaeaeeaaeaeeaaaeeeeeaaeeaaaa

output:

22

result:

ok single line: '22'

Test #50:

score: 0
Accepted
time: 2ms
memory: 3508kb

input:

yeeyyyyeyyyeyyeeyyyeeyyeeeyyeeyyyeeeeeeyeeyyeeyyeeyyyyeyeeeeeyeyeyeyyeyyyeeeeeeyyeyyeyyyyyyeyyeyeye

output:

21

result:

ok single line: '21'

Test #51:

score: 0
Accepted
time: 2ms
memory: 3480kb

input:

mummmuumuummmuuumumuumummmumumuumuuuuumumuuuumummummmumuummuumummmumuuummmmuummumummuuuuummuumuuumu

output:

22

result:

ok single line: '22'

Test #52:

score: 0
Accepted
time: 2ms
memory: 3480kb

input:

cnnnncncncnccnncnncncccnnccnccnncccnnncccnccccnncnnnnncccnccccnnncccccnccncncncccccncnncnccncnccnnc

output:

18

result:

ok single line: '18'

Test #53:

score: 0
Accepted
time: 2ms
memory: 3484kb

input:

iiirriiirriiiriirrririrrriiririirriiriiriiiirrririrrrrrriirrriiiirriiiiiiiriiiirrririiriiiiirririrr

output:

17

result:

ok single line: '17'

Test #54:

score: 0
Accepted
time: 2ms
memory: 3364kb

input:

kkkkkkekeekkeekekkkeeekkkekeekeekkkeeeeekkekkeekekkekkkeeekeeekeeekkkkkkekkeekkekkekekkeeeekekekeek

output:

19

result:

ok single line: '19'

Test #55:

score: 0
Accepted
time: 2ms
memory: 3612kb

input:

gdddggdddggdddddgggddgdddgggdddgdgdggdgddgdddddgggggddddggggddddgddgdgddgddgggdgdgggddggdgdgddgdgdg

output:

19

result:

ok single line: '19'

Test #56:

score: 0
Accepted
time: 0ms
memory: 3344kb

input:

piipippppippiiiippiiipppiipppiiiiipiippiiiipiipipiiippppippipipippppipiipppippippppipiipippppiipipp

output:

18

result:

ok single line: '18'

Test #57:

score: 0
Accepted
time: 2ms
memory: 3488kb

input:

kfppkkfkpfkppffpppffkkfkpppfkpppppkkfffkkfppfffkfpppkppffpfpkffkkppppkpffpkpkpkkkfkpkfkkpkpkpfkpkpk

output:

19

result:

ok single line: '19'

Test #58:

score: 0
Accepted
time: 2ms
memory: 3420kb

input:

ggaaaamggmmgaagagaagmgggmamgggmmammmaaggggmaaaaggagmmmgmaaggagagmaaammmmammgagmgamgagaaamggaamgagga

output:

21

result:

ok single line: '21'

Test #59:

score: 0
Accepted
time: 2ms
memory: 3496kb

input:

phhnphhnphnphhnnpnhpppnnhnnpphnpnnhhhphnpnnhnpnpphphhhhpphnphnnpphpnhnhnhhhnphhhppnphnphnhhpnhphnhn

output:

23

result:

ok single line: '23'

Test #60:

score: 0
Accepted
time: 2ms
memory: 3588kb

input:

ebbbebeeeeebzzbezzbbbzebzebzeezzeebzzeeebzebebbezezebbeezzzbzbbeezezbbezezbeeebbzebzzezezbbeebzezee

output:

17

result:

ok single line: '17'

Test #61:

score: 0
Accepted
time: 0ms
memory: 3432kb

input:

hhhttatththhaahthhhataaaahaaaahahhaahhtttahhaataaahthhataahaahhttahaththhhhhahaatthaahatahaahaahtha

output:

21

result:

ok single line: '21'

Test #62:

score: 0
Accepted
time: 2ms
memory: 3420kb

input:

ycccsysccsscycsysyyycsyssssscycyyccccycyycssssysscsycscssscscyyycyysycsysyyccscyyscccyycysycsycyycs

output:

20

result:

ok single line: '20'

Test #63:

score: 0
Accepted
time: 2ms
memory: 3664kb

input:

hhphpjhhhjhjphjjpjhpphhhpjppphpjpphjhpppjhhjpphjjphpppjppphppjhhphjpjphjhppjhpppjjjhjhjhjjjjhppphph

output:

23

result:

ok single line: '23'

Test #64:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

assjjsssajajssssssasjsasjsjjajasjjassaassasaajjssjjsasasaasjjjjasaajsssasaaaasjssjajaasajsajsjsjjja

output:

20

result:

ok single line: '20'

Test #65:

score: 0
Accepted
time: 2ms
memory: 3500kb

input:

cwwkwkcwwcwwckwwwkkcwkcckkkwwcwcwkkkckwkwcwkcckkwkwkkcckckwkwcckcwcwkcwckkckwkwkkcwkkcwwkcccckkwwkk

output:

19

result:

ok single line: '19'

Test #66:

score: 0
Accepted
time: 2ms
memory: 3524kb

input:

plpwplwplpwllppllppllwwpwwwllplwlwwlplwplppwlplwlppwplllwwplpwlwppllpllwllwlwppwlpppwwwwwlppwwplwlp

output:

22

result:

ok single line: '22'

Test #67:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

cchrrhrwwrrwhwrrcrhwchhhhwwhhwchhcwwrhrwhhwwcwhwrcwwrwrrhhwwrwhcwchcwhwrcwrcrhcrrcrwwcwcrccrccccrrr

output:

22

result:

ok single line: '22'

Test #68:

score: 0
Accepted
time: 2ms
memory: 3476kb

input:

hjjhhrjhhrgrghggrrjrrrrgrjhhjjrrggrjrgjghrrhjghjhrggrjjhrrgrhggrgjgjhjhhghhjrgrhjggggjjhjrhghrhhrhr

output:

19

result:

ok single line: '19'

Test #69:

score: 0
Accepted
time: 2ms
memory: 3508kb

input:

wfwnfnfwccwnfcfwwnfwnfwfcccfccwffnwcncncfcwwnwwccccnnfwccffcfncwfccfwnnnwnwncccfcwfffcnfwwwwwwnncnc

output:

22

result:

ok single line: '22'

Test #70:

score: 0
Accepted
time: 1ms
memory: 3484kb

input:

bgbbwxbxggggxxwwwbbwxxgwgxwgwbxbgbwwwwbgggxwbwxgwxwbxgxwxwbwgbxwxxwwbxbbwxwgwgwxxgxgxwbwxgwxbbwxgbw

output:

23

result:

ok single line: '23'

Test #71:

score: 0
Accepted
time: 2ms
memory: 3480kb

input:

zwzwzzcwczzzzwcwmmzmcczwmwzzzwcccczzwzzzczwcwmccwzmccmwwcccwzcwzcwzmwwzwcmwcccwccwczmmzwzmwcwcwmmcc

output:

22

result:

ok single line: '22'

Test #72:

score: 0
Accepted
time: 1ms
memory: 3600kb

input:

abbbybbaxabbxbyyxbxbxxxxyybbayaabxaxabxybxbybbaaxbyybyyaxybayxyxybxbxbyyaxaybbyyyayyxxbxbabybxabxyy

output:

22

result:

ok single line: '22'

Test #73:

score: 0
Accepted
time: 1ms
memory: 3508kb

input:

grzrzrrrzggggrgzkzrkzrggkgkkkrgzrzkzzgzkrkzkgkkrzzgkzzrzrgkkzkzkgzrkgrgkzgrzrzkgkzrgkrrrrkrrkrrkkzg

output:

24

result:

ok single line: '24'

Test #74:

score: 0
Accepted
time: 1ms
memory: 3500kb

input:

xxmxyxdmdyymmxmmxdmyyyxmdmxymxyymmyyymdymyydxymyxxyyddmdydyxxdmxxdyxdmdyxyddxdxydxddmmyxyydymmymddm

output:

21

result:

ok single line: '21'

Test #75:

score: 0
Accepted
time: 2ms
memory: 3484kb

input:

grgffrrgfrrrfbfgbbrfggbrbbbgfrbgrbgfgfgbgfbrrrrrbfbgbbbbfffbfrrrrfrrbbgfgffrfbggrrrfbrrgrgfrffrbrgr

output:

24

result:

ok single line: '24'

Test #76:

score: 0
Accepted
time: 0ms
memory: 3420kb

input:

wgfguufuufgwfugwwugffgwgffgufgfufugwffgwuwguwufuguwuwwfwuwfguguuugfggufgufuwufuwfwwwwgwgwgfgffuuguu

output:

23

result:

ok single line: '23'