Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
51632 一碗石榴真有趣~ 最优子序列 C++ 运行出错 0 0 MS 316 KB 414 2022-07-13 12:20:15

Tests(0/20):


#include <iostream> #include <cstdio> using namespace std; int n,k,ty; string s,t; int ans=0; bool u[26]; void dfs(int p,int d) { if(p==n) { ans=max(ans,d); return ; } if(u[s[p]]==0 || (u[s[p]] && s[p]==t[d])) { t[d+1]=s[p]; u[s[p]]=1; dfs(p+1,d+1); if(s[p]!=t[d]) u[s[p]]=0; } dfs(p+1,d); } int main() { cin>>n>>k>>ty; cin>>s; dfs(0,0); cout<<ans<<endl; return 0; }


测评信息: