500E : NEW YEAR DOMINO

Правка en4, от ds_95, 2015-11-17 15:03:35

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

My submission :14311431

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.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en7 Английский ds_95 2015-11-17 15:06:53 0 (published)
en6 Английский ds_95 2015-11-17 15:06:28 8 (saved to drafts)
en5 Английский ds_95 2015-11-17 15:04:55 0 (published)
en4 Английский ds_95 2015-11-17 15:03:35 6
en3 Английский ds_95 2015-11-17 15:03:01 12
en2 Английский ds_95 2015-11-17 15:02:37 28
en1 Английский ds_95 2015-11-17 15:01:39 648 Initial revision (saved to drafts)