500E : NEW YEAR DOMINO

Revision en7, by ds_95, 2015-11-17 15:06:53

Please help me debug my solution for this problem NEW YEAR DOMINO

My submission :14311924

My Idea :

--Treat each domino as an interval.

--Then find connected components based on intersection.

--Store range of each connected component i.e. minL,maxR.

--for each query a,b

--define cost(cc[a],cc[b]) as cost of going from one connected component to another.

--cost(cc[a],cc[b]) = minL[cc[b]]-maxR[cc[a]] (given b>a).

--However min cost = sum of costs (starting from cc[a]) to next one till cc[b] reached.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en7 English ds_95 2015-11-17 15:06:53 0 (published)
en6 English ds_95 2015-11-17 15:06:28 8 (saved to drafts)
en5 English ds_95 2015-11-17 15:04:55 0 (published)
en4 English ds_95 2015-11-17 15:03:35 6
en3 English ds_95 2015-11-17 15:03:01 12
en2 English ds_95 2015-11-17 15:02:37 28
en1 English ds_95 2015-11-17 15:01:39 648 Initial revision (saved to drafts)