Блог пользователя thefarzibruno

Автор thefarzibruno, 11 лет назад, По-английски

Can any help me give a solution using top down (memo + recursion) technique,for some reason my solution isn't counting all the possible answers,please help me as i'm new to dp. http://mirror.codeforces.com/problemset/problem/163/A http://ideone.com/AEMNUw

Теги dp
  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
11 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Your rec(i, 0) actually counts only such pairs where x starts at position i. You never increase i unless s[i] == s[j];. res += rec(i, 0) for all i < s.size();