WA for Arrgraph of Snackdown1A

Can any1 provide testcases for which my program is failing?

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

Thanks.

@vatsalsura
A counter-case for your solution is :

1
8
46 45 38 27 38 42 33 45

Here, your code should replace 42 with a prime number to connect it to the graph( since it is disconnected having gcd > 1 with all other numbers) but instead your code prints the same input array without changing any !

Expected output : (Just one of any correct outputs)
1
46 45 38 27 38 29 33 45

1 Like

I appreciate you pointing out the TC for wrong answer in my code.
I now know the obvious flaw in my solution. I was just checking if there were n-1 edges already available instead on checking if it was connected.

Thanks I really appreciate it.

1 Like
//