Graph Theory Complete video series : part 1 (9 july2020 - 1 editorial added)

24 May 2020 : 1 video added
L18 : Applying dfs on 2D Grid

1 Like

Brother can you make explanation video on bipartite matching using DSU?if you have time :smiley:
Edit: FILLMTR Problem - CodeChef or add a editorial for this in DSU series.

bipartite matching itself is a different concept , so first i need to teach that , then I may make editorial for this problem.

Thanks for suggestion btw.

2 Likes

28 May 2020 : 2 lecture added.
L19 : Counting connected components on grid
E01 : Counting Rooms | CSES | Graph Algorithms

3 Likes

Please add more videos in the graph series part2 of other algorithms

what lecture you think I should add in that series ?

1 Like

30 May 2020 : 1 new lecture added
L20 : BFS on 2D Grid

2 Likes

good job bro…you helped many of d begginers with the frigthening topics…this has helped me a lot…jazakumallah khair

1 Like

thank you :slight_smile:

2 Likes

3 June 2020 : 1 video added
E001 : Jungle Run | HackerEarth | Graph & Tree

3 Likes

mistake in else if loop of dfs function else if(color[src]==color[x]), this one comes in place of your condition

First of all , i think you didn’t see there are two testcases. So for first test case n=3 , m=3 and for second test case n=4 m=2.

Brother both are same either i will use color[src] or c , because i pass c by call by call it means everytime a new copy is geneated, So i m sure that it is correct , I think there is an fault in another line

nice1

You are live motivation bro !!! thanks a lot for all your efforts :innocent:

1 Like

Can someone tell me if these lectures are useful for INOI ?

Need Help to find the mistake
I am getting WA.
I looked at your solution.
but can’t find the mistake.

import java.util.;
import java.lang.
;

class Main
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner(System.in);
int test=sc.nextInt();

	for(int t=1;t<=test;t++)
	{
		int n=sc.nextInt();
		int m=sc.nextInt();
		int visited[]=new int[n+1];
		int color[]=new int[n+1];
		Map<Integer,List<Integer>> al=new HashMap<>();
		for(int i=1;i<=n;i++)
			al.put(i,new ArrayList<Integer>());
		for(int i=0;i<m;i++)
		{
			int u=sc.nextInt();
			int v=sc.nextInt();
			al.get(u).add(v);
			al.get(v).add(u);
		}
		boolean ans=true;
		for(int i=1;i<=n;i++)
		{
			if(visited[i]==0)
			{
				boolean ca=check(i,0,al,visited,color);
				if(ca==false)
					ans=false;
			}
		}
		
		System.out.println("Scenario #"+t+":");
		
		if(ans==false)
		{
			System.out.println("Suspicious bugs found!");
		}
		else
		{
			System.out.println("No suspicious bugs found!");
		}
	}
}
public static boolean check(int v,int c,Map<Integer,List<Integer>> al,int visited[],int color[])
{
	visited[v]=1;
	color[v]=c;
	//System.out.println("trace "+v+" "+color[v]);
	for(int node:al.get(v))
	{
		if(visited[node]==0)
		{
			c=c^1;
			boolean ans=check(node,c,al,visited,color);
			if(ans==false)
				return false;
		}
		else
		{
	//		System.out.println("tr "+v+" "+color[v]+" "+node+" "+color[node]);
			if(color[v]==color[node])
				return false;
		}
	}
	return true;
}

}

In the counting rooms problem on CSES, I have used the same algorithm used in video but I am still getting TLE on test cases 9 and 10. What is happening? I’m using python 3. Did anyone’s python solution get accepted?
Code is here.

which problem are you solving?

in dfs function you are passing visited array and I am not sure if in python function calls are by reference or by value.

if python follows call by value then you need to stop passing visited array and define it globally

1 Like