Comments

yeah this logic is incorrect because i might miss some of the edges which could help reduce the overall cost see this example copied from above cmt

5

5 15

19 13

19 13

24 14

20 13

2 10 20 10 2

6 4 2 4 5

For problem D, can somebody point out what's wrong in my approach

  1. first iterate over all cities one by one

  2. for each city i , find the minimum of all costs to connect this city j ( 1 <= j <= n) let's call it min_cost

  3. now we have two scenario either this city i has its own power house or is connected to some other city which will have a power house

  4. just compare C[i] with min_cost

    a. if(C[i] < min_cost) , we can simply have a individual plant for this city
    
     b. otherwise we connect this to city j, which gave us min_cost
  5. now we have a graph with

  6. simply iterate over all connected components

  7. for each component find the minimum C[i] and add it to final cost answer, since we are planting a power plant at this i'th city

  8. rest of this connected component let's just find the MST and add this to final answer , since all the other cities would be connected to some other city with wires having power connection

  9. repeat 7

My Submission

i figured out the error in my code, fixed it and got it AC, thanks for the nicest and simple solution compared to the editorial

looks like you haven't tested this algorithm yourself, because i have implemented the exact same logic but this solution gets TLE, i just can't make out.

Can someone please help find whats wrong here : My Submission

Any help for problem m F

did u get how is this code working ?

in regards to (above mentioned solution) this , can you please explain these two lines

  1. for(i=1;i<=n;++i) lst[i]+=n-i;

what is the purpose of adding "n-i" to every lst , and what values will "lst" will hold after this.

  1. ans=lower_bound(lst+1,lst+n+1,t)-lst; ans=t-(n-ans+1);

how is this calculating answer

Please find the error in my code i don't know what's going wrong here My Submission for Problem D

Have you tried this also on the test cases ?

+8

Two doubts for problem D editorial

  1. how did you conclude this " This means that we can just find balances, and greedily match vertices with positive balance to vertices with negative balance.The total debt is then Σd=∑v|bal(v)|2 , and it is clear that we cannot do better than that"

  2. how do we find the final debts i.e. the second half of the answers , the remaining edges.

thanks man, easier than the editorial

AnyOne who can help me with Grid Shuffle problem at least the approach

Thanks a ton brother

Can someone help find out why the hell am i getting runtime error,(problem F1) my submisssion https://mirror.codeforces.com/contest/1203/submission/58887999

a

Shouldn't the L array be calculated on right of i'th element instead of j < i and similarly for R array , If I'm wrong correct me , you are trying to calculate for each i'th element the no of elements which are lesser than a[i] to its left and right (to whatever position we can extend the left and right boundaries )

0

Bro can u explain how are you able to calculate no i*i % m = k for a particular val

what is the inital value of dp ( i mean before recurring loop )

On majkGood Bye 2018 — Editorial, 7 years ago
0

why k can't be 5 in above case

one type of bracket or just any one bracket (i don't get the logic for above example) , also then how come answer to 6 (((()) is 3