-3

This is an 2013 Local INOI Informatics Olympiad Question.

Suppose we have 1393 points on real axis. we want to color this points such that for each arbitrary interval [a, b], if at least one point of 1393 points be in interval, at least one point inside the interval has different color with other points in this interval. with how many colors this can be done? (best answer is 11).

INOI Commit say short answer with 11. How we can calculate this question?

  • The question looks incomplete. As far as I understand it 2 colors are enough. Just alternate the colors of the points. – Dialecticus Mar 27 '15 at 10:54
  • 1
    @Dialecticus: That's exactly what I thought at first. Then I read the question more carefully: for each interval, there must be a point whose colour is different from all other points in the interval. For instance, this is not the case for an interval containing four points coloured B,W,B,W. – TonyK Mar 27 '15 at 10:56
  • 1
    What does this have to do with programming? – Mark Dickinson Mar 27 '15 at 10:57
  • I think this is very tricky question :) @Dialecticus –  Mar 27 '15 at 10:57
  • @MarkDickinson programmer has creative mind :) I Think. –  Mar 27 '15 at 10:58
  • The answer is probably `ceil(log2(N))`... – Dialecticus Mar 27 '15 at 10:59
  • @Dialecticus: I think it's `floor(log2(N))+1` (which is different from `ceil(log2(N))` for exact powers of two). – TonyK Mar 27 '15 at 11:12
  • 2
    I'm voting to close this question as off-topic. – David Eisenstat Mar 27 '15 at 11:53
  • Could someone who understands the question please translate it to English? – Marc Glisse Mar 27 '15 at 11:55
  • 2
    @MarcGlisse: You have a set S of N points on the real line. Each point of S gets assigned one of k colors. This in such a way that whenever the intersection of S and some [a,b] is not empty, there is one color so that only and exactly one point of that color is in the intersection. Obviously, if every point has its own color, k=N, this is satisfied. Task: For N=1393 determine the minimal number k with that property. – Lutz Lehmann Mar 27 '15 at 14:37

2 Answers2

4

Claim

The most points you can colour with k colours is 2^k-1.

Proof

If we have 0 colours, then clearly we can colour no points, so this is true for k==0.

For k>0, we use induction.

Consider the interval containing all the points. There must be 1 colour that appears exactly once. Consider the points to the left of this point. These points are coloured with k-1 colours, so there can be at most 2^(k-1)-1 of them.

Similarly, there are at most 2^(k-1)-1 to the right.

So in total there can be at most 1+2^(k-1)-1+2^(k-1)-1=2^k-1 points with k colours.

2^10-1=1023, 2^11-1=2047, so this shows a lower bound of 11 colours for your case, and TonyK has given a construction showing that this can be achieved.

Peter de Rivaz
  • 33,126
  • 4
  • 46
  • 75
  • This answer almost makes mine redundant -- it immediately suggests the construction that I described. – TonyK Mar 27 '15 at 13:43
  • @TonyK there are at most 2^(k-1)-1 to the right. means there are 2^(k-1)-1 points? –  Mar 27 '15 at 15:24
  • there are at most 2^(k-1)-1 to the right. means there are 2^(k-1)-1 points? –  Mar 27 '15 at 17:00
2

If the colour of the nth point is determined solely by the number of trailing zeroes in the binary expansion of n, then the condition is satisfied. We can do this with 11 colours for up to 2047 points.

The converse -- can we do it with fewer points -- is another question.

Example for 15 points:

Binary Trailing zeroes Colour
------ --------------- ------
1      0               blue
10     1               red
11     0               blue
100    2               green
101    0               blue
110    1               red
111    0               blue
1000   3               yellow
1001   0               blue
1010   1               red
1011   0               blue
1100   2               green
1101   0               blue
1110   1               red
1111   0               blue
TonyK
  • 16,761
  • 4
  • 37
  • 72
  • I couldn't get it. is it possible make an example for clarify? –  Mar 27 '15 at 11:03
  • @Dialecticus, please you add this nice idea as an answer. –  Mar 27 '15 at 11:11
  • +1 Tonyk, but what do u mean by "The converse -- can we do it with fewer points -- is another question." please add more detail to your answer. –  Mar 27 '15 at 11:11
  • @MaryamGhizhi: I have shown that 11 colours are enough. But I haven't shown that 10 colours are not enough. – TonyK Mar 27 '15 at 11:14
  • yeah, there is any proof? –  Mar 27 '15 at 11:22
  • @Dialecticus I couldn't get the relevant of your oeis link with this problem, please clarify me –  Mar 27 '15 at 14:40
  • @MaryamGhizhi The only relevance is that given oeis sequence is the same (with offset 1) as the sequence that TonyK had showed. There is no deep mathematical thought behind the link that I gave. – Dialecticus Mar 27 '15 at 15:41
  • how I can calculate the sequence for 1393 ? I cannot find this sequence calculated from which series? @Dialecticus –  Mar 27 '15 at 15:44
  • @MaryamGhizhi The original question does not ask for this sequence. Answer to original question is just one number. You don't need this sequence. I gave you the link to the sequence just for additional fun and knowledge. – Dialecticus Mar 27 '15 at 18:04
  • 1
    @Maryam: Just continue my example sequence until you reach 1393. The hardest part will be thinking up seven more colour names. – TonyK Mar 27 '15 at 18:24
  • @TonyK in other answer "there are at most 2^(k-1)-1 to the right". means there are 2^(k-1)-1 points? –  Mar 27 '15 at 18:25
  • @MaryamGhizhi: Umm...right is the opposite of left. – TonyK Mar 27 '15 at 18:58