Cyber attack problem


can you tell me where I am wrong I just made the MAximum spanning tree just opposite to the kruskal’s algorithm and I tried to keep those edges which are making cycle in maximum spanning tree because only in that case if we will remove that edge there will be another path to go there so in the end whole graph will remain connected as given in question and sorted the array of edges in increasing order as I want to add only those edges to maximum spanning tree which I donot want to take because of more weight as I need to keep those edges which is having less weight in that case I will be able to hack more number of edges.and it run perfectly fine for the given test case but donot know why answer is not comming and please tell error in my code only:)

Hey @Love buddy
I ran your code on sample cases and it worked fine
The logic also seems perfect
Issue is with the weights
You have used int while weight can be upto 10^12 so you need to use long long there
That will solve your troubles

If your doubt is resolved please close it

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.