Under the Tunnels : LTIME80 Jan 2020 Video editorial

you can find the editorial here

Under the Tunnels : LTIME80

There are other editorials and course too like graph theory , number theory , disjoint set and so on which my channel offer.

suggestions are welcome.

thank you for your valuable time.
CodeNCode

1 Like

Will you upload CARR?

Will really appreciate if u do :slightly_smiling_face:

already working on it bro , will be uploaded til morning , i have solved that problem already though.

1 Like

Thanks a lot ! :slightly_smiling_face:

you’re welcome man

@waqar_ahmad224 Please make part 2 of graph tutorials too. Your number theory series is awesome.

soon i will start working on that too

1 Like

Can anybody help me what is wrong with my solution.I m doing the dfs on the nodes which can be visited in optimal jumps,if at any tile there is no landable tiles in my radar then i make a back jump so as to check wheter upto k backs tiles can give me the jump greater than current i,if not then i check whether i reached the nth tile or not if not i returned -1,
if yes then returned the no of jumps…
This is link to my submission
https://www.codechef.com/viewsolution/29177676

Please Can Any One tell me why my following Code is not working ???
I tried so much but i could not get why it’s not give me correct answer.
Please Help.

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define ff first
#define ss second

vector<vector<pair<ll,ll> > > adj;
vector<bool> vis;
vector<ll> lvl;
void bfs(ll k,ll n)
{
    queue<pair<ll,ll> > q;
q.push({1,0});
while(!q.empty())
{
    auto a=q.front();
    q.pop();
    if(vis[a.ff]) continue;
    vis[a.ff]=1;
    if(a.ff == n){lvl[n]=a.ss;break;}
    for(auto x:adj[a.ff])
    {
        
        if(!vis[x.ff] && abs(x.ff - a.ff )<=k)
        {
            q.push({x.ff,a.ss+1});
            lvl[x.ff]=a.ss+1;
            // vis[x.ff]=1;
        }
        }
}
}

int main()
{
ll t,n,k,t1;
cin>>t;t1=t;
while(t--)
{
    cin>>n>>k;
    string s[n+1];
    adj.resize(n+1);
    vis.resize(n+1);
    lvl.resize(n+1);
    // memset(vis,0,sizeof vis);
    for(ll i=0;i<=n;i++) lvl[i]=-1;
    for(ll i=0;i<=n;i++) vis[i]=0;
    // for(ll i=0;i<=n;i++) lvl[i]=-1;
    
    for(ll i=1;i<=n;i++)
    {
        cin>>s[i];
        for(ll j=0;j<n;j++)
        {
            if(s[i][j]=='1' && i!=(j+1)) adj[i].pb({j+1,-1});
        }
    }
    // queue<ll> q;
    lvl[0]=0;lvl[1]=0;
    bfs(k,n);
    cout<<lvl[n]<<"\n";
}
return 0;
}

thank you for such great content


Here you go.
1 Like

You are welcome man.