For example, look at how Benjamin Qi does it: https://codeforces.com/contest/1446/submission/98447974
The actual code is at the bottom. Here is a sample of a submission to a problem harder than your usual AoC second part:
int main() { setIO(); re(N,M); str A,B; re(A,B); F0R(i,N+2) F0R(j,M+2) mx[i][j] = -MOD; int ans = 0; R0F(i,N) R0F(j,M) { ckmax(mx[i][j],mx[i+1][j]); ckmax(mx[i][j],mx[i][j+1]); if (A[i] == B[j]) { dp[i][j] = 2; ckmax(dp[i][j],mx[i+1][j+1]+4+i+j); ckmax(mx[i][j],dp[i][j]-i-j); ckmax(ans,dp[i][j]); } } ps(ans); }
For example, look at how Benjamin Qi does it: https://codeforces.com/contest/1446/submission/98447974
The actual code is at the bottom. Here is a sample of a submission to a problem harder than your usual AoC second part: