Bottom up DP for AIBPHOBIA problem from SPOJ

I have just solved AIBPHOBIA problem from SPOJ. Here is my aced solution through which I have got accepted.

Can anyone please help me in converting my top-down DP solution to bottom-up DP solution.