Snakes and Ladders doubt


#1

Kindly find bug in this
failing for this test case

int Solution::snakeLadder(vector<vector > &a, vector<vector > &b) {
map<int,int>l;
map<int,int>s;
for(auto p:a)
{
l[p[0]]=p[1];
}
for(auto p:b)
{
s[p[0]]=s[1];
}
int mov=0;
queueq;
q.push(1);
bool f=false;
vectorvis(101,0);
vis[1]=true;
while(!q.empty() && !f)
{
int st=q.size();
while(st–)
{
int t= q.front();
q.pop();
for(int d=1;d<=6;d++)
{
if(t+d==100)
{
f=true;

            }
            if(t+d<= 100 && l[t+d] && !vis[l[t+d]])
            {
                vis[l[t+d]]=true;
                if(l[t+d]==100)
                {
                    f=true;
                }
                q.push(l[t+d]);
            }
            if(t+d<=100 && s[t+d] && !vis[s[t+d]])
            {
                vis[s[t+d]]=true;
                if(s[t+d]==100)
                {
                    f=true;
                }
                q.push(s[t+d]);
            }
            else if(t+d<=100 && !vis[t+d] && !s[t+d] && !l[t+d])
            {
                vis[t+d]=true;
                q.push(t+d);
            }
        }
        
    }
    mov++;
  
}
  if(f)
    {
        return mov;
    }
    else
    {
        return -1;
    }

}