Hi,
I get WA on test case 23
Problem Link ==> https://mirror.codeforces.com/problemset/problem/73/C
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e2+5;
string s;
long long k,change;
long long dp[MAXN][27][MAXN];
map<char,map<char,long long> > adjList;
long long Max(long long i,long long prev,long long left){
if(i==s.size()) return 0;
if(dp[i][prev][left]!=-1) return dp[i][prev][left];
long long res=Max(i+1,(int)s[i],left) + adjList[prev][s[i]];
if(left!=0){
for(int j=97;j<=122;++j){
char now = (char)(j);
if(now==s[i]) continue;
long long ind = Max(i+1,j,left-1) + adjList[prev][now];
res = max(res,ind);
}
}
dp[i][prev][left] = res;
return dp[i][prev][left];
}
int main()
{
for(long long i=0;i<=100;++i){
for(long long j=0;j<=26;++j){
for(long long f=0;f<=100;++f) dp[i][j][f] = -1;
}
}
cin >> s;
cin >> k >> change;
for(long long i=0;i<change;++i){
char a,b;long long c;cin >> a >> b >> c;
adjList[a][b]=c;
}
cout << 1ll * Max(0,'?',k);
}
Thanks in advance:)
Why don't you hire someone as your personal debugger
You can start from Tomorrow
Auto comment: topic has been updated by BanazadehAria (previous revision, new revision, compare).