Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
51797 | AK2022071340 | 最优子序列 | C++ | 运行出错 | 0 | 0 MS | 84 KB | 1401 | 2022-07-13 14:44:13 |
using namespace std; char c[3005]; int p[3005]; int f[9005][3005]; int last[26]; string s[9005][3005]; int n,k,type; void pre() { for(int i=1; i<=n; i++) { int num=c[i]-'a'+1; if(!last[num]) continue; if(last[num]==i) p[i]=0; else p[i]=last[num]; last[num]=i; } } int tp[26]; int ts; int main() { scanf("%d%d%d",&n,&k,&type); getchar(); for(int i=1; i<=n; i++) { c[i]=getchar(); int num=c[i]-'a'+1; if(!last[num]) last[num]=i,tp[num]=++ts; } pre(); for(int i=1; i<1<<(ts+1); i++) for(int j=1; j<=n; j++) { int num=tp[c[j]-'a'+1]; if(1<<num&i) { f[i][j]=f[i-(1<<num)][j-1]+1; s[i][j]=s[i-(1<<num)][j-1]+c[j]; int tmp=f[i][p[j]]+1; if(tmp>f[i][j]) f[i][j]=tmp,s[i][j]=s[i][p[j]]+c[j]; else { if(tmp==f[i][j]&&s[i][j-1]<s[i-(1<<num)][p[j]]) s[i][j]=s[i][p[j]]+c[j]; } } else f[i][j]=f[i][j-1],s[i][j]=s[i][j-1]; } int maxn=0,maxi; string ans; int k=(1<<(ts+1))-1; for(int i=1; i<=n; i++) if(f[k][i]>maxn) maxn=f[k][i],ans=s[k][i]; else if(maxn&&f[k][i]==maxn&&s[k][i]<ans) ans=s[k][i]; printf("%d\n",maxn); if(type) printf("%s\n",ans.c_str()); return 0; }
20 12 0
jhlbfajhlbfajhlbfaag
10
exit code: 0, checker exit code: 0
20 12 0
ehjbehjbehjbkhlckhlc
10
exit code: 0, checker exit code: 0
200 4 0
abababababababababababababababababababababababababababababdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdaadcbcbcbcbcbcbc...
101
exit code: 0, checker exit code: 0
200 4 0
dbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcccccccccccccccccccccccccccccccccccccccccccccccccdcdcdcbb...
128
exit code: 0, checker exit code: 0
200 12 0
idljidljidljidljidljidljidljidljidljidljidljidljidljidljidljidljidljidljidljidljidljidljidljidljidljidljidljidljidljidljidljidljidljidljidljidljelhdelhdelhdelhdelhdelhdelhdelhdkdliehfichficl...
57
exit code: 0, checker exit code: 0
200 12 0
gbalfgbalfgbalfgbalfgbalfgbalfgbalfgbalfgbalfgbalfgbalfgbalfgbalfgbalfgbalfgbalfgbalfgbalfgbalfgbalfgbalfgbalfaebgaebgjahldijahldijahldijahldijahldijahldijahldijahldijahldijahldijahldicgkhea...
47
exit code: 0, checker exit code: 0
200 12 1
cgiahcgiahcgiahcgiahcgiahcgiahcgiahcgiahcgiahcgiahcgiahcgiahcgiahcgiahcgiahcgiahcgiahcfacfacfacfacfacfacfalkcglkcglkcglkcglkcglkcglkcglkcglkcglkcglkcglkcglkcglkcglkcglkcglkcglkcglgfalgfaifbi...
54
aaaaaaaaaaaaaaaaaaaaaaaalkccccccccccccccccccggfffbbbbi
exit code: 0, checker exit code: 0
200 12 1
gacbegacbegacbegacbegacbegacbegacbegacbegacbegacbegacbegacbegacbegacbegacbegacbegacbegacbegacbegacbekfjkfjkfjkfjkfjkfjkfjkfjkfjkfjkfjcekgdcekgdcekgdcekgdcekgdcekgdcekgdcekgdcekgdiefajiefajie...
51
aaaaaaaaaaaaaaaaaaaabekkkkkkkkkkkkdddddddddfffjjicg
exit code: 0, checker exit code: 0
200 12 2
jaeiljaeiljaeiljaeiljaeiljaeiljaeiljaeiljaeiljaeiljaeiljaeiljaeiljaeiljaeiljaeiljaeiljaeiljaeiljaeiljaeiljaeiljaeiljaeiljaeiljaeiljaeiljaeiljaeiljaeiljaeiljaeiljaeiljaeiljaeilhalkhalkhalkcjg...
48
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaeihhhcjfkbdgl
exit code: 0, checker exit code: 0
200 12 2
jhgajhgajhgajhgajhgajhgajhgajhgajhgajhgajhgajhgajhgajhgajhgajhgajhgajhgajhgajhgajhgajhgajhgajhgajhgajhgajhgajhgajhgajhgajhgajhgajhgacjlfedcjlfedcjlfedcjlfedcjlfedcjlfedcjlfedcjlfedcjlfedcjlf...
51
hgaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaacccccccccccjlfed
exit code: 0, checker exit code: 0
3000 12 0
fejbhfejbhfejbhfejbhfejbhfejbhfejbhfejbhfejbhfejbhfejbhfejbhfejbhfejbhfejbhfejbhfejbhfejbhfejbhfejbhfejbhfejbhfejbhfejbhfejbhfejbhfejbhfejbhfejbhfejbhfejbhfejbhfejbhfejbhfejbhfejbhfejbhfejb...
607
exit code: 0, checker exit code: 0
3000 12 0
dhefjdhefjdhefjdhefjdhefjdhefjdhefjdhefjdhefjdhefjdhefjdhefjdhefjdhefjdhefjdhefjdhefjdhefjdhefjdhefjdhefjdhefjdhefjdhefjdhefjdhefjdhefjdhefjdhefjdhefjdhefjdhefjdhefjdhefjdhefjdhefjdhefjdhef...
661
exit code: 0, checker exit code: 0
3000 12 1
eihdjeihdjeihdjeihdjeihdjeihdjeihdjeihdjeihdjeihdjeihdjeihdjeihdjeihdjeihdjeihdjeihdjeihdjeihdjeihdjeihdjeihdjeihdjeihdjeihdjeihdjeihdjeihdjeihdjeihdjeihdjeihdjeihdjeihdjeihdjeihdjeihdjeihd...
837
hddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddiiiiiiiiiiiiiiiiiiiiiiiiiiii...
exit code: 0, checker exit code: 0
3000 12 1
ekjdlekjdlekjdlekjdlekjdlekjdlekjdlekjdlekjdlekjdlekjdlekjdlekjdlekjdlekjdlekjdlekjdlekjdlekjdlekjdlekjdlekjdlekjdlekjdlekjdlekjdlekjdlekjdlekjdlekjdlekjdlekjdlekjdlekjdlekjdlekjdlekjdlekjd...
607
ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd...
exit code: 0, checker exit code: 0
3000 12 2
jbhflkjbhflkjbhflkjbhflkjbhflkjbhflkjbhflkjbhflkjbhflkjbhflkjbhflkjbhflkjbhflkjbhflkjbhflkjbhflkjbhflkjbhflkjbhflkjbhflkjbhflkjbhflkjbhflkjbhflkjbhflkjbhflkjbhflkjbhflkjbhflkjbhflkjbhflkjbh...
585
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbhfkaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
exit code: 0, checker exit code: 0
3000 12 2
gbjaekgbjaekgbjaekgbjaekgbjaekgbjaekgbjaekgbjaekgbjaekgbjaekgbjaekgbjaekgbjaekgbjaekgbjaekgbjaekgbjaekgbjaekgbjaekgbjaekgbjaekgbjaekgbjaekgbjaekgbjaekgbjaekgbjaekgbjaekgbjaekgbjaekgbjaekgbj...
517
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
exit code: 0, checker exit code: 0
3000 12 2
fjladfjladfjladfjladfjladfjladfjladfjladfjladfjladfjladfjladfjladfjladfjladfjladfjladfjladfjladfjladfjladfjladfjladfjladfjladfjladfjladfjladfjladfjladfjladfjladfjladfjladfjladfjladfjladfjla...
629
fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff...
exit code: 0, checker exit code: 0
3000 12 2
fdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihfdihf...
758
ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd...
exit code: 0, checker exit code: 0
3000 12 2
dhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgjbdhgj...
615
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...
exit code: 0, checker exit code: 0
3000 12 2
jlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbdgjlbd...
583
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...
exit code: 0, checker exit code: 0