Whats wrong in my code test cases are passed not getting ac

Ouch. That’s very misleading.

1 Like

For this question, if |S| \neq |T|, the answer is no, right?

Yep. Directly "NO.

This got accepted, but this is a slightly different dfs logic. However, I’d like to find out why the bool dfs() version was failing.

1 Like

Haha, that’s the exact train of thought that I went through. But you can change ‘a’ to ‘b’, even if there is no direct mapping. Like, it’s still possible if we have a->t and t->b maps. Hence, dfs.

1 Like

Well. not necessarily.

s = ab
t = xy
6
a->t
b->t
t->x
t->y

Realized this after my epic fail → here

1 Like

Yes, I missed that.

1 Like

The problem with this code is if |S| \neq |T|, your function doesn’t take in m and the mappings because you return nothing from the function immediately. This input gets piled up and goes to the next test cases where your program gets messed up.

1 Like

ARGHHHHHHHHHHHH! I cannot believe I did this again. You have a really good eye! Thank you so much!

1 Like

I can sleep in peace. AC.
I was also not clearing the adjacency list by returning immediately.

1 Like

Sleep well XD

1 Like

i have checked length after in putting mappings

Can you post your submission link? It’s hard to see what you’ve done here.

https://www.codechef.com/viewsolution/34897956

got any thing

Nope, sorry.
Here is my submission if it helps: CodeChef: Practical coding for everyone

i have done the same thing

i got the mistake bro
it is intialising visted =0;in the following line
if(!dfs(a[i]-‘a’)){decide=1;break;}

1 Like

Cool.

hello bro how u solved covid sampling question in june long can you explain me

1 Like

I have posted my approach here.
Do reply back here if you need any clarification!