GALACTIK - Editorial

“If any component has all planets having negative taxes, then answer is -1”

What if this is true, but there is only one component? Then, surely, the answer is 0 and not -1.

Have you checked this case?

6 Likes

Apart from this, the steps you said are right.

thanks bro, for your help…now it got accepted.

@tijoforyou What is the mistake with the following code. My code has exactly the same logic as yours, just the way of implementation differs: OOQUBQ - Online C++ Compiler & Debugging Tool - Ideone.com

https://www.codechef.com/viewsolution/26802191
I am not able to understand where my logic is wrong…Can anybody explain the mistake…Thanks in advance!

Why my solution is not getting accepted. It says wrong answer on submission.
My solution
Can anyone help me in this.

Thanks a lot. It really helped me.:blush:

Why did you added (components-2)global_min ?

Okay so let the number of vertices in the different connected components be d_1\leq d_2\leq d_3\cdot \leq d_k.The minimum answer here will clearly be
(d_1+d_2)+(d_1+d_3)+\cdots +(d_1+d_k) = d_1*(k-1) + (d_2+d_3\cdots d_k)=d_1*(k-1)+(d_1+d_2+\cdots d_k)-d_1=d_1*(k-2)+sum

What is the meaning of cost double star?

What is cost** ?

I am getting WA for the following code. I have used the same approach as in the editorial. https://www.codechef.com/viewsolution/28846480. Can someone help me to figure out the problem with my code.

can u plz exaplain me “sum + (ncc-2)*min_cost”.
why isnt just “sum”…why extra (ncc-2)*min_cost?
Thanks.

can you eloborate plz…i still dint undertsand.

hey i have the same doubt…did u get the reason?

through dfs make sure u r handling corner cases as well,eg if(n==1) or there is only one component,etc.

thanks! @admin make solution providers to do like this. I mean to say that it would be helpful if you provide code with a lot of comments explaining each step so that we can easily grasp it and also it decreases a lot of load in discuss. Saves a lot of time. Thanks!

Trying with the following approach.
https://www.codechef.com/viewsolution/31915365
Considered the boundary cases as well…stil WA.

Hey… @srij_kh
consider this test case…
6 3
1 2
3 2
5 6
1
-1
-1
1
1
-1

Answer: 4
your output:3

Hope it helps!!!

1 Like

trying with the following approach : Coding Blocks IDE
considered all the corner cases as well like all -1 tax, number of components = 1.
Still WA.