i am not understanding whats wrong in my code, i was getting runtime error till i declared the vector<vector> v globally and now WA, i have take bottom up approach : code:
const int maxH = 15;
const int maxN = (1<<15) - 1;
void solve(int h)
{
vector<vector> v(maxH, vector(maxN, 0));
int n = 1LL<<(h - 1);
for(int i = 0; i<h; i++)
{
for(int j = 0; j < (1LL<<i); j++)
cin>>v[i][j];
}
for(int i = h - 2; i>-1; i--)
{
for(int j = 0, k = 0; j<(1LL<<(i + 1)); j++, k+=2)
{
v[i][j] = (v[i][j] * max(v[i + 1][k], v[i + 1][k + 1]))%mod;
}
}
cout<<v[0][0]%mod<<endl;
}
int32_t main()
{
ios_base ::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
while(1)
{
cin>>t;
if(t == 0)
break;
solve(t);
}
}