You are not logged in. Please login at www.codechef.com to post your questions!

×

Covering: ZCO 2015

How do I solve the Interval Covering Problem from ZCO 2015???

asked 03 Jan '15, 21:55

arpanb8's gravatar image

3★arpanb8
1201312
accept rate: 13%


First sort the input sets according to their starting points. Now start considering 2 sets at a time, in the beginning the 1st and 2nd set. There are 3 cases which will come up.
1)the 2nd set is disjoint from the first one. eg. (1,3) & (5, 19)
2) the 2nd set is contained within the first one. eg. (1, 10) & (3, 7)
3) the 2nd set starts within the first set but ends after it.

Think about how you should approach each of these conditions.
HINT: At times you will increment the total points and at times you will change what sets to consider. This problem gets solved linearly.

link

answered 04 Jan '15, 00:22

Organic-Shilling's gravatar image

0★Organic-Shilling
93118
accept rate: 11%

@arpanb8 You got the algorithm? If anybody needs help beyond this they can ask.

(04 Jan '15, 23:26) Organic-Shilling0★
(05 Jan '15, 19:53) arpanb83★

But @Organic-Shilling isn't the worst case complexity O(N^2)? How does it get solved linearly? Although, O(N^2) is enough for this problem...

(05 Jan '15, 20:28) sandy9992★

yep...that is a q. that struck me 2...But n2 is enough for this prob...

(05 Jan '15, 20:29) arpanb83★
toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×989
×56
×37

question asked: 03 Jan '15, 21:55

question was seen: 793 times

last updated: 05 Jan '15, 20:29