Superjump in a grid (Hackerearth July Easy 21) [Solved]

Question : https://www.hackerearth.com/challenges/competitive/hackerearth-july-easy-21/algorithm/superjump-in-a-grid-773f1e31/

My solution(WA) : “4hU83P - Online C++0x Compiler & Debugging Tool - Ideone.com

My solution(AC) : “7zqZ0S - Online C++0x Compiler & Debugging Tool - Ideone.com

I got 98 in contest too , and same in practice also I m not able to figuring out where my code wrong , also sometime it will give WA at TC 11 , and sometime it’s WA on TC 14 , may be some compiler or run time error issue.

@ssjgz @cubefreak777 @dhruv788

2 3
110
100

Correct output: 0
Your output: 1

2 Likes

Thanks , I just changed -


    for(int i=0;i<m;i++)
    {
        if(a[0][i]==0)
            dp[0][i] = 1;
        else
            dp[0][i] = 0;
    }
 
    for(int i=0;i<n;i++)
    {
         if(a[i][0]==0)
            dp[i][0]=1;
        else
            dp[i][0]=0;
    }

TO


    for(int i=0;i<m;i++)
    {
        if(a[0][i]==0 and a[0][0]==0)
            dp[0][i] = 1;
        else
            dp[0][i] = 0;
    }
 
    for(int i=0;i<n;i++)
    {
         if(a[i][0]==0  and a[0][0]==0)
            dp[i][0]=1;
        else
            dp[i][0]=0;
    }

It passed :slight_smile:

1 Like