Friday 15 July 2011

c - How to optimize space for SPOJ AIBOHP -


I was making this special problem and based on the investigation of the end of the substrings beginning with the length of the DP approach Had used. Although the complexity of my time is fine on O (N ^ 2) but the space is taking too much, due to which I am getting RTE, if I declare it dynamic or TLE, then declaring it as a global condition I need to reduce the DP size can be 6100 * 6100.

  He now asks doctors to put the minimum number of characters required to make S.:  

The problem statement is: A For example, if doctors need to change the string for "tfft", add only 1 character

and my The code is:

  Fixed Ent DP [6101] [6101]; Main () {int TC; Scanf ("% d", & amp; tc); While (TC -) {char s [6102]; Scanf ("% s", s); Int len ​​= strlen (s); MEMSAT (DP, 0, DP of size); For (int i = 1; i & lt; len; i ++) (int j = 0, k = i; k    

Your argument is correct.

I made a change in your code DP [6101] [6101] to constant low DP [6101] [6101] is changing. Yes, declaring it as a short, it helps to avoid memory windage and AC.

You can check for yourself!

No comments:

Post a Comment