QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#511719#2273. Suffixes may Contain Prefixescocoa_chanAC ✓243ms44660kbC++172.0kb2024-08-10 10:20:032024-08-10 10:20:03

Judging History

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

  • [2024-08-10 10:20:03]
  • 评测
  • 测评结果:AC
  • 用时:243ms
  • 内存:44660kb
  • [2024-08-10 10:20:03]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll inf=1e9;
ll n,m,i,j,k,l,r,x,y,z,w,s,t,a[1100000],adj[2200][30],mx[2200][30],b[1100000],dp[2200][2200],pos[2200];
char c[1100000];
int main()
{
    scanf("%s",c);
    n=strlen(c);
    scanf("%lld",&m);
    for(i=1;i<=n;i++)
    {
        a[i]=c[i-1]-'a'+1;
    }
    adj[0][a[1]]=1;
    mx[0][a[1]]=1;
    for(i=1;i<=n;i++)
    {
        /*printf("%lld:",i);
        for(j=0;j<=26;j++)
            printf("%lld",pos[j]);
        printf("\n");
*/
        for(j=1;j<i;j++)
        {
            if(!pos[j])
                continue;
            //adj[i][a[i+1-j+1]]++;
            /*if(mx[i][a[i+1-j+1]]==0)
            mx[i][a[i+1-j+1]]=(j);*/
            adj[i][a[i+1-j+1]]++;
            mx[i][a[i+1-j+1]]=max(mx[i][a[i+1-j+1]],i+1-j+1);
        }
        if(a[i]==a[1])
        {pos[i]=1;
        adj[i][a[2]]++;
        mx[i][a[2]]=max(mx[i][a[2]],ll(2));
        }
        mx[i][a[1]]=max(mx[i][a[1]],ll(1));
        adj[i][a[1]]++;
        for(j=1;j<=i;j++)
        {
            if(a[i+1]!=a[i+1-j+1])
                pos[j]=0;
        }
    }
 /*   for(i=1;i<=n;i++)
    {
        for(j=0;j<=26;j++)
            printf("(%lld,%lld) ",adj[i][j],mx[i][j]);
        printf("\n");
    }
  */  /*for(i=0;i<m;i++)
    {
        for(j=0;j<=26;j++)
        {
            dp[i+1][mx[i][j]]=max(dp[i+1][mx[i][j]],dp[i][j]+adj[i][j]);
        }
    }*/
    for(i=1;i<=n;i++)
        dp[0][i]=-inf;
        for(i=1;i<=m;i++)
            for(j=0;j<=n;j++)
            dp[i][j]=-inf;
    for(i=0;i<m;i++)
    {
        for(j=0;j<=n;j++)
        {
            for(k=1;k<=26;k++)
            {
                dp[i+1][mx[j][k]]=max(dp[i+1][mx[j][k]],dp[i][j]+adj[j][k]);
            }
        }
    }
    s=0;
    /*for(i=1;i<=m;i++)
    {
        for(j=0;j<=26;j++)
            printf("%lld ",dp[i][j]);
        printf("\n");
    }*/
    for(j=0;j<=n;j++)
    {
        s=max(s,dp[m][j]);
    }
    printf("%lld",s);
}

详细

Test #1:

score: 100
Accepted
time: 7ms
memory: 10352kb

input:

fsfffsfffssfsfffsfsfffsfffffsfffsfffssfsfffsfsfffsffssfffsfffsfffssfsfffsfsfffsfffffsfffsfffssfsfffsfsfffsffssfffsfffsfffssfsfffsfsfffsfffffsfffsfffssfsfffsfsfffsffssfffsfffsfffssfsfffsfsfffsfffffsfffsfsfsfffsfffssfsfffsfsfffsfffffsfffsfffssfsfffsfsfffsffssfffsfffsfffssfsfffsfsfsfsfffsfffssfsfffsfsf...

output:

852

result:

ok single line: '852'

Test #2:

score: 0
Accepted
time: 48ms
memory: 28460kb

input:

ddttddttddttddddtdddttddttddttdddddttddttddtddttddttddttddddtdddttddttddttdddddttddttddttddttddttddttddddtdddttddttddttdddddttddttddtddttddttddttddddtdddttddttddttddddddttddttddttddddtdddttddttddttdddddttddttddtddttddttddttddddtdddttddttddttdddddttddttddttddttddttddttddddtdddttddttddttdddddttddttddt...

output:

5894

result:

ok single line: '5894'

Test #3:

score: 0
Accepted
time: 232ms
memory: 42860kb

input:

wswswwwswswswwwsswswswwwswswswwwswswwwswswswwwsswswswwwswswwswswwwswswswwwsswswswwwswswswwwswswwwswswswwwsswswswwwswswssswwswwswswwwswswswwwsswswswwwswswswwwswswsswswswwwswswswwwsswswswwwswswswwwswswwwswswswwwsswswswwwswswwswswwwswswswwwsswswswwwswswswwwswswwwswswswwwsswswswwwswswssswwswwswswwwswsws...

output:

10500

result:

ok single line: '10500'

Test #4:

score: 0
Accepted
time: 31ms
memory: 26224kb

input:

sjsspffsjsspfsjsspffsjssjsspffsjsspfsjsspffsjsspsjsspffsjsspfsjsspffsjssjfsjsspffsjsspfsjsspffsjssjsspffsjsspffsjsspfsjsspffsjssjsspffsjsspfsjsspffsjsspsjsspffsjsspfsjsspffsjssjfsjsspffsjsspfsjsspffsjssjssjsspffsjsspfsjsspffsjssjsspffsjsspfsjsspffsjsspsjsspffsjsspfsjsspffsjssjfsjsspffsjsspfsjsspffsj...

output:

4267

result:

ok single line: '4267'

Test #5:

score: 0
Accepted
time: 231ms
memory: 42804kb

input:

mmpmmmpmmpmpfmzmmpmmmmmpmmmpmmpmpmmpmmmpmmpmpmmpmmmppmmpmmmpmmpmpfmzmmpmmmmmpmmmmmpmmmmpmmmpmmpmpfmzmmpmmmmmpfqmmpmmmpmmpmpfmzmmpmmmmmpmmmpmmpmpmmpmmmpmmpmmmpmmmpmmpmpfmzmmpmmmmmpmmmpmmpmpmmpmmmpmmpmpmmpmmmppmmpmmmpmmpmpfmzmmpmmmmmpmmmmmpmmmmpmmmpmmpmpfmzmmpmmmmmpfqmmpmmmpmmpmpfmzmmpmmmmmpmmmpmmpmpm...

output:

9536

result:

ok single line: '9536'

Test #6:

score: 0
Accepted
time: 25ms
memory: 26488kb

input:

pepypopepepypopepypopepepyzpepypopepepypoperpepypopepepypopepypopepepyzpepypopepepypgakpepypopepepypopepypopepepyzpepypopepepypepypopepepypopepypopepepyzpepypopepepypoperpepypopepepypopepypopepepypopepepypopepypopepvplpepypopepepypopepypopepepyzpepypopepepypoperpepypopepepypopepypopepepyzpepypopepep...

output:

4033

result:

ok single line: '4033'

Test #7:

score: 0
Accepted
time: 232ms
memory: 41408kb

input:

fifuurfifuugfifuurfifufifuurfifuugfifuurfifuefifuurfifuugfifuurfifufifuurfifuugfiffifuurfifuugfifuurfifufifuurfifuugfifuurfifuefifuurfifuugfifuurfifufifuurfifuugfyqnfifuurfifuugfifuurfifufifuurfifuugfifuurxvfifuurfifuugfifuurfifufifuurfifuugfifuurfifuefifuurfifuugfifuurfifufifuurfifuugfiffifuurfifuu...

output:

9452

result:

ok single line: '9452'

Test #8:

score: 0
Accepted
time: 15ms
memory: 24296kb

input:

gwgxlggwgxihdggwgxlggwcgwgxlgwgxlmgwgxlgwgxlggwgxihdggwgxlggwcgwtxgwgxlggwgxihdggwgxlggwcgwgxlgwgxlmgwgxlgwgxlggwgxihdggwgxlggwcgwgxlgwgxlmgwgxlgwgxlggwgxihdggwgxlggwcgwtxgwgxlggwgxihdggwgxlggwcgwgxrgwgxlggwgxihdggwgxlggwcgwgxlgwgxlmgwgxlgwgxlggwgxihdggwgxlggwcgwtxgwgxlggwgxihdggwgwvgwgxlggwgxihdggw...

output:

3584

result:

ok single line: '3584'

Test #9:

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

input:

aabaacaabaa
101

output:

249

result:

ok single line: '249'

Test #10:

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

input:

aabaacaabaa
102

output:

251

result:

ok single line: '251'

Test #11:

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

input:

aabaacaabaa
103

output:

253

result:

ok single line: '253'

Test #12:

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

input:

aabaacaabaa
104

output:

255

result:

ok single line: '255'

Test #13:

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

input:

aabaacaabaa
105

output:

257

result:

ok single line: '257'

Test #14:

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

input:

cciccpccicc
2000

output:

4995

result:

ok single line: '4995'

Test #15:

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

input:

lkultxuuxtkltukllulxkltuutkuuttkuxutuuxuutuxtkxktklltllulkltxtttkkkxxtuxltkxtxtttlltttlkkkutkkuxulklxuuxullkkxtktlxtutuxlktkkllxutlllxkltkutxltxtlluxxlxxxklxlluuxllllxxlllluktkxtkutluktxkkukluktkkuktlkkultukulxlxkltlllkkluluutkxlxkuktktxxtkkkkkuxtxttkxtuxkkttklltulktltxkutluuulluxtuxlllltlutxulxxltk...

output:

1

result:

ok single line: '1'

Test #16:

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

input:

zrszgeggmmagjcibhsuuugohqppnncuuksrynidfbmhaqpnzswblenhttvtgadwjybijjwhixqppgzqajdqbmjrgaziljastkonutvyqrxtvshhoidkixodyrekyshlafxnikbgaqegxbgwmpgbxnpkdxhnhcocmbpimftogrlydyqitekbfvtimiztujfejkomujzztadjhrvdqlakxnbctuaubumwlwyibmyjabrrdznkvndghplgqjmcvqhmgbsrnpmjjbkkqmnvzczlpsrgdmsmmcgksbkhzatnpiwch...

output:

2

result:

ok single line: '2'

Test #17:

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

input:

xxiiixxhhhxxiiixx
1996

output:

4187

result:

ok single line: '4187'

Test #18:

score: 0
Accepted
time: 3ms
memory: 42860kb

input:

xxiiixxhhhxxiiixx
1997

output:

4190

result:

ok single line: '4190'

Test #19:

score: 0
Accepted
time: 8ms
memory: 44660kb

input:

xxiiixxhhhxxiiixx
1998

output:

4192

result:

ok single line: '4192'

Test #20:

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

input:

xxiiixxhhhxxiiixx
1999

output:

4194

result:

ok single line: '4194'

Test #21:

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

input:

xxiiixxhhhxxiiixx
2000

output:

4196

result:

ok single line: '4196'

Test #22:

score: 0
Accepted
time: 4ms
memory: 42804kb

input:

xxiiixxhhhxxiiixxicpcicpc
2000

output:

4196

result:

ok single line: '4196'

Test #23:

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

input:

c
123

output:

123

result:

ok single line: '123'

Test #24:

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

input:

p
2000

output:

2000

result:

ok single line: '2000'

Test #25:

score: 0
Accepted
time: 4ms
memory: 14356kb

input:

nananananananananananananananananananananananananananananananananananananananananananananananananananananananananananananananananananananananananananananananananananananananananananananananananananana
500

output:

40100

result:

ok single line: '40100'

Test #26:

score: 0
Accepted
time: 15ms
memory: 10340kb

input:

czgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczgczg...

output:

1717

result:

ok single line: '1717'

Test #27:

score: 0
Accepted
time: 225ms
memory: 42704kb

input:

fjlpvbnxxxfjlpvbnxxxfjlpvbnxxxfjlpvbnxxxfjlpvbnxxxfjlpvbnxxxfjlpvbnxxxfjlpvbnxxxfjlpvbnxxxfjlpvbnxxxfjlpvbnxxxfjlpvbnxxxfjlpvbnxxxfjlpvbnxxxfjlpvbnxxxfjlpvbnxxxfjlpvbnxxxfjlpvbnxxxfjlpvbnxxxfjlpvbnxxxfjlpvbnxxxfjlpvbnxxxfjlpvbnxxxfjlpvbnxxxfjlpvbnxxxfjlpvbnxxxfjlpvbnxxxfjlpvbnxxxfjlpvbnxxxfjlpvbnxxx...

output:

201000

result:

ok single line: '201000'

Test #28:

score: 0
Accepted
time: 229ms
memory: 42736kb

input:

uuarrprirpprxppuuarrprirpprxppuuarrprirpprxppuuarrprirpprxppuuarrprirpprxppuuarrprirpprxppuuarrprirpprxppuuarrprirpprxppuuarrprirpprxppuuarrprirpprxppuuarrprirpprxppuuarrprirpprxppuuarrprirpprxppuuarrprirpprxppuuarrprirpprxppuuarrprirpprxppuuarrprirpprxppuuarrprirpprxppuuarrprirpprxppuuarrprirpprxpp...

output:

134469

result:

ok single line: '134469'

Test #29:

score: 0
Accepted
time: 38ms
memory: 26384kb

input:

ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff...

output:

440469

result:

ok single line: '440469'

Test #30:

score: 0
Accepted
time: 243ms
memory: 41232kb

input:

qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq...

output:

2001000

result:

ok single line: '2001000'

Test #31:

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

input:

a
1

output:

1

result:

ok single line: '1'

Test #32:

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

input:

z
1

output:

1

result:

ok single line: '1'

Test #33:

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

input:

cc
1

output:

1

result:

ok single line: '1'

Test #34:

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

input:

gg
1

output:

1

result:

ok single line: '1'

Test #35:

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

input:

yx
2

output:

2

result:

ok single line: '2'

Test #36:

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

input:

tr
2

output:

2

result:

ok single line: '2'

Test #37:

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

input:

xxyxxyx
20

output:

49

result:

ok single line: '49'