Casey And Gifts

Can you please tell me what is wrong in this programme

  1. We count one when both of the person is not marked
    else if any of one will marked we simple marked their place but not increment count.

Please either format your code or link to your submission - the forum software has mangled it and it won’t compile! :slight_smile:

1 Like

It works fine on sample test case …
Which test case is failing here

You are only considering one group and always grouping it as ‘1’. There can be multiple groups. Sample test case is passing because there are only two groups. Seems like you are just considering whether they are visited or not, not exactly grouping. Also, you have to consider when both belongs to different groups, which is missing in your code.

Need help for my code:
Trying to know where it went wrong. I know I didn’t use union-find algorithm, but I want to know which case is missing, as I’m getting WA.
https://www.codechef.com/viewsolution/27945900

You are just considering two groups and that’s why your code is passing sample test cases. You can create a graph and do dfs on it to find the different connected components or else you can use DSU. My approach with DSU:-

Hope it helps!!

Can someone help with my code too, please?

Posting link again: CodeChef: Practical coding for everyone