Code not wokring

It passes one test case but gives run time error for the rest.
code-https://ide.codingblocks.com/s/343617

hello @amanb25
a)
increase the size of cnt array (because number of components can be greater than 100)
b) use long long in place of int

code-https://ide.codingblocks.com/s/343617… I tried doing that it gives line dump error

@amanb25

all pair are counted twice so u need to print ans/2 in place of ans/p

It still gives segmentation fault, i changed that to 2 and removed the variable p

declare ur all array of size 1000 05.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.