I used a dfs for finding no. of connected component. If this return >1 then answer would be 0. Can you please explain this?
@ay2306 Actually in this case, my code could pass but i have found another case something like u mentioned above. It was my fault, i forgot that cases and thats why got partial marks.
@anon87574747 Yes, my code failed for tc2 and 9. Actually i had some logical mistake so got partial marks.
My code failed for:
ggdgg
ggggg
ggdgg
@aman_2k18 It means i have to make graph disjoint i.e. if i start with any ‘g’ index then not able to visit each ‘g’ index. So, i am using dfs starting with any ‘g’ index and check whether i am able to visit each ‘g’ index or not. If not, then it proves that this graph contains more than 1 ‘g’ connected component. Hence answer would be 0.
If anybody gets mail from sharechat, please share
I think almost all of us failed for the test case when g\leq 2 and they are connected. In that case, we have to remove both g's. Because removing only one would make the other g connected with itself. But as per our logic, we were removing only one of them. So basically, when g\leq 2, then print g as the answer.
even i tried doing the same thing but got WA on all testcases. Later used binary search with prefix sum and it worked. though the logic is still the same.
Same question, is it restricted to only a few colleges? I hope someone replies
Makes sense ! Idk why I used algorithm for finding articulation point.
What about
d d d
d g d
d d d
Case ?
Ans should be 1 right ?
Had you missed this case or am I missing anything ?
Edit : Just read it fails with many more cases.
I did this.
Did you get full score on the question?
how exactly ???
Atleast I know, our approach is correct.
Ohh, I didn’t know.
I think at least the test files were correct.
which contest is this ques of?
That’s secret
nice one