it is partially submitting on hackereart
K order LCS problem
- You are creating much larger arrays than required. Reduce their sizes.
ll dp[2002][2002][6];
ll a[2002], b[2002];
These should be enough. - Do not use your for loop macro. You have written it wrong. Just simply use the for loop.
- Also I would suggest you to not to use memset function and initialise the dp array as -1 yourself loops.
for(ll i=0;i<=n;i++){
for(ll j=0;j<=m;j++){
for(ll l=0;l<=k;l++){
dp[i][j][l] = -1;
}
}
} - Use fast input-output .
Copy these 2 statements and paste them as the first two statements of your code. These come as the first statements in main( ) and then keep the rest of your main( ) as it is.
ios_base::sync_with_stdio(false);
cin.tie(NULL); - Use return 0; statement at the end of your code. Trust me … it matters. Your code legitimately failed one testcase for this, not joking.