Answers to: TLE in Family of Recurrenceshttps://discuss.codechef.com/questions/51340/tle-in-family-of-recurrences<p>Here is the <a href="http://www.codechef.com/problems/KAN13D">problem</a>.</p>
<p>I have implemented matrix multiplication to solve the recurrence relation. the order of the solution should be O(m^3 * log(n) * T) which is approximately 32 * 10^6 * 20 = 64 * 10^7, which should be done in 1 sec.The time limit of the problem is 15 sec, still I am getting TLE.</p>
<p>Please Help, here is <a href="http://www.codechef.com/viewsolution/4856788">my solution</a></p>enSun, 21 Sep 2014 02:16:14 +0530Answer by neo1tech9_7https://discuss.codechef.com/questions/51340/tle-in-family-of-recurrences/51392<p>Try using 2 d arrays instead of vector < vector < long long > > as you have to clear them for each test case (which you are not doing and will result in wa) and resize() function also has complexity O(n) if i remember correctly. Also declare the arrays globally.</p>neo1tech9_7Sun, 21 Sep 2014 02:16:14 +0530https://discuss.codechef.com/questions/51340/tle-in-family-of-recurrences/51392