A question about segment paint

Правка en4, от Trath, 2017-07-22 20:25:16

This question came up when i misread a USACO question. The actual USACO question is much easier (I think).

The question

Let's suppose that we have a game played as follows:
In the beginning, we have two arrays V and W, both of size n. W is filled with some colors (the colors are represented as numbers from 1 to 100000000) and V is a blank array (all the cells have zero as color). We play in rounds, and at each round we can choose for every color at most one segment [L, R] and paint all of V's cells from L to R with the given color. In a round, we can only choose for every color at most one segment, and all choosen segments need to be disjoint. We need to print the minimum number of rounds need to transform V into W.

Sample Input:
8 (The value of N)

3 4 3 7 3 2 2 4 (the array W)

Sample Output :
2

Explanation: In the first round we can paint the segment [0,4] with the color 3 , the segment [5,6] with the color 2 and the segment [7,7] with the color 4. V == 3 3 3 3 3 2 2 4
In the second round we can paint the segment [1,1] with the color 4 and the segment [3,3] with the color 7 , and V == W
PS: I don't have a polynomial solution yet , and i took a while thinking about this, if anyone can solve this in polynomial time, or give me some bound of the complexity, it will be great :)
Edit : Bump 1!

Теги usaco, maybegreedy, gimesolution, unsolved

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en4 Английский Trath 2017-07-22 20:25:16 15 Tiny change: ':) <br>\nED1: BUMP! ' -> ':) <br>\nEdit : Bump 1!'
en3 Английский Trath 2017-07-22 20:24:27 18 Tiny change: 'e great :)' -> 'e great :) <br>\nED1: BUMP! '
en2 Английский Trath 2017-07-21 09:03:37 35
en1 Английский Trath 2017-07-21 08:53:00 1434 Initial revision (published)