Maths Olympiad Prep

Library / /101 of 101

Combinatorics Difficulty 7.8 National olympiad, round 2 Prove it Estonia

Fix a natural number nn. A function f:{0,1,,n}{0,1,,n}f : \{0, 1, \dots, n\} \to \{0, 1, \dots, n\} is called regular if f(0)=0f(0) = 0 and f(i){i1,f(i1),f(f(i1)),}f(i) \in \{i-1, f(i-1), f(f(i-1)), \dots\} for every i=1,,ni = 1, \dots, n. If, for instance, n=3n = 3, then the function f(0)=f(1)=0,f(2)=f(3)=1f(0) = f(1) = 0, f(2) = f(3) = 1 is regular, but the function f(0)=f(1)=f(2)=0,f(3)=1f(0) = f(1) = f(2) = 0, f(3) = 1 is not (in the latter case, f(3)f(3) violates the regularity condition). Juku chooses a regular function ff and tells Miku for each number k=0,1,,nk = 0, 1, \dots, n, how many different arguments ii are there such that f(i)=kf(i) = k. Can Miku always determine based on this information which regular function Juku had chosen?

Solutions — 4

Solution 1

Firstly, we prove by induction that if ff is a regular function then f(i)<if(i) < i for each positive argument ii. For that, assume that the claim holds for all smaller arguments. We have f(i){i1,f(i1),f(f(i1)),}f(i) \in \{i-1, f(i-1), f(f(i-1)), \dots\} by regularity. By the induction hypothesis and the assumption f(0)=0f(0) = 0, we have i1f(i1)f(f(i1))i-1 \ge f(i-1) \ge f(f(i-1)) \ge \dots. Hence f(i)<if(i) < i indeed.

Now we prove by induction on nn that the information given to Miku by Juku uniquely determines the regular function. If n=0n = 0 then only one regular function exists whence the claim holds trivially. Assume in the rest that n>0n > 0 and that the claim holds for all smaller numbers. As f(1)<1f(1) < 1 by the lemma proven in the beginning, we must have f(1)=0f(1) = 0.

Let kk be the largest number in {0,1,,n}\{0, 1, \dots, n\} such that f(k)=0f(k) = 0. Then k1k \ge 1 since f(1)=0f(1) = 0. By the lemma proven in the beginning, 0<ik0 < i \le k always implies f(i)<if(i) < i and hence also f(i)<kf(i) < k. On the other hand, k<ink < i \le n implies f(i)kf(i) \ge k. Indeed, assume that f(j)kf(j) \ge k for each j=k+1,,i1j = k+1, \dots, i-1; let exactly ss initial members of the sequence i1,f(i1),f(f(i1)),i-1, f(i-1), f(f(i-1)), \dots be larger than or equal to kk. Then the ssth member must be kk because otherwise the ss initial members would all be in {k+1,,i1}\{k+1, \dots, i-1\}, implying that the next member would be larger than or equal to kk, too. Thus the next member is f(k)f(k) which equals 0 and all following members are 0, too. But as f(i)0f(i) \ne 0, we must have f(i)kf(i) \ge k. We can conclude that the number of arguments ii such that f(i)kf(i) \ge k is exactly nkn-k.

Now if 0<l<k0 < l < k then similarly to what we did before we can prove that 0<il0 < i \le l always implies f(i)<lf(i) < l. But among the arguments ii such that l<inl < i \le n, there is kk for which f(k)=0f(k) = 0. Thus the number of arguments ii such that f(i)lf(i) \ge l is less than nln-l. Consequently, kk is the least positive integer for which the number of arguments ii such that f(i)kf(i) \ge k is nkn-k. According to this property, Miku can determine kk.

Restricting ff to {0,1,,k1}\{0, 1, \dots, k-1\}, all conditions of regularity hold. Hence, by the induction hypothesis, Miku can determine f(1),,f(k1)f(1), \dots, f(k-1). Note that if we forget about arguments 1,,k1, \dots, k and decrease the other argument-value pairs of ff by exactly kk, the conditions of regularity again hold. Hence, by the induction hypothesis, Miku can also determine f(k+1),,f(n)f(k+1), \dots, f(n). Consequently, Miku can determine the values of ff at all its arguments.

Solution 2

We start like in Solution 1 by showing that if ff is regular then f(i)<if(i) < i for every positive argument ii.

Now we prove the following lemma: Whenever 0<kin0 < k \le i \le n, either f(i)kf(i) \ge k or f(i)f(k)f(i) \le f(k). To this end, fix kk and proceed by induction on ii. The base case i=ki = k is trivial. Assume now that i>ki > k and, for every ii' such that ki<ik \le i' < i, either f(i)kf(i') \ge k or f(i)f(k)f(i') \le f(k). By regularity, f(i)f(i) is a term in the sequence i1,f(i1),f(f(i1)),i-1, f(i-1), f(f(i-1)), \dots. This sequence decreases until it reaches zero. Let the sequence contain exactly ss terms larger than or equal to kk. As all terms are less than ii, the induction hypothesis implies that the term number s+1s+1 is at least kk (which is impossible by the choice of ss) or at most f(k)f(k). Then the following terms are also at most f(k)f(k). Thus f(i)f(i) must be either at least kk or at most f(k)f(k).

Miku can determine Juku's regular function as follows. Let Miku put the numbers of repetitions of values in the order of decreasing value (i.e., the number of repetitions of nn first, then the number of repetitions of n1n-1, etc.). Every time a number of repetitions of some value kk equals a positive number aa, let Miku define the value of ff on the least aa arguments greater than kk where the value is not defined so far to be kk. We show that this results in the only possible regular function with the given numbers of repetitions of values. Suppose the contrary. Let kk be the largest value of the function for which a divergence appears. We know that all arguments on which the function obtains the value kk must be larger than kk. Hence there exist ii' and ii such that k<i<ik < i' < i, f(i)=kf(i) = k and f(i)kf(i') \neq k. Since all values greater than kk are already assigned by the algorithm and they are correct by the choice of kk, the only option is f(i)<kf(i') < k. But then the lemma proven above implies either f(i)i>kf(i) \ge i' > k or f(i)f(i)<kf(i) \le f(i') < k, contradiction. Consequently, no divergence between the actual function and the one constructed by the algorithm can arise. Hence Miku can always determine Juku's function.

Solution 3

Like in Solution 1, we show that if ff is regular then f(i)<if(i) < i for every positive argument ii. Like in Solution 2, we show that 0<kin0 < k \le i \le n always implies either f(i)kf(i) \ge k or f(i)f(k)f(i) \le f(k).

Miku can determine Juku's regular function as follows. Let Miku start by defining f(0)=0,f(1)=0f(0) = 0, f(1) = 0. These are clearly the only options. Whenever f(0),f(1),,f(i1)f(0), f(1), \dots, f(i-1) have been fixed, let Miku define f(i)f(i) to be the largest number among 0,1,,i10, 1, \dots, i-1 whose presumed number of occurrences is not achieved yet. As f(i)<if(i) < i, such number must exist. We show now that this definition is the only possible. Suppose the contrary. Let the first divergence arise at the definition of f(i)f(i). Let the algorithm assign the value kk to it; then actually f(i)<k<if(i) < k < i, because the algorithm finds the largest number less than ii that can be used. But since the value kk is not yet saturated, there must exist ii' such that i>ii' > i and f(i)=kf(i') = k. By the lemma proven at the beginning of the solution, either f(i)i>kf(i') \ge i > k or f(i)f(i)<kf(i') \le f(i) < k, contradiction. Hence Miku can always determine Juku's function.

Now we prove by induction on nn that the information given to Miku by Juku uniquely determines the regular function. For n=0n=0, there exists only one regular function, whence the claim holds. Assume in the following that n>0n > 0 and the claim holds for n1n - 1. Let a0,a1,,ana_0, a_1, \dots, a_n be the numbers of repetitions of values of ff. By the property proven at the beginning of the solution, nn cannot occur among the values of ff, hence an=0a_n = 0. Let ll be the least positive integer such that al=0a_l = 0. As al1>0a_{l-1} > 0, we have f(l)=l1f(l) = l - 1 by the above. Define b0,b1,,bn1b_0, b_1, \dots, b_{n-1} by
bi={ai,if i<l1,ai1,if i=l1,ai+1,if il. b_i = \begin{cases} a_i, & \text{if } i < l - 1, \\ a_i - 1, & \text{if } i = l - 1, \\ a_{i+1}, & \text{if } i \ge l. \end{cases}
Note that b0,b1,,bn1b_0, b_1, \dots, b_{n-1} are the numbers of repetitions of values of function gg defined by
g(i)={f(i),if i<l,f(i+1),if f(i+1)<li,f(i+1)1,if l<f(i+1). g(i) = \begin{cases} f(i), & \text{if } i < l, \\ f(i+1), & \text{if } f(i+1) < l \le i, \\ f(i+1) - 1, & \text{if } l < f(i+1). \end{cases}
In other words, function gg is obtained from ff by removing the argument-value pair (l,l1)(l, l-1) (this removes the only occurrence of ll in these pairs) and decreasing the numbers l+1,,nl+1, \dots, n by 1 in all other pairs. It is easy to check that regularity of ff implies regularity of gg. By the induction hypothesis, gg is the only regular function with numbers of repetitions of values are b0,b1,,bn1b_0, b_1, \dots, b_{n-1}. But ff can be defined in terms of gg:
f(i)={g(i),if i<l,l1,if i=l,g(i1),if g(i1)<l<i,g(i1)+1,if lg(i1). f(i) = \begin{cases} g(i), & \text{if } i < l, \\ l-1, & \text{if } i = l, \\ g(i-1), & \text{if } g(i-1) < l < i, \\ g(i-1)+1, & \text{if } l \le g(i-1). \end{cases}
In other words, add the argument-value pair (l,l1)(l, l-1) and increase all numbers l,,n1l, \dots, n-1 by 1 in other pairs. This completes the solution.

Solution 4

Like in Solution 1, we show that if ff is regular then f(i)<if(i) < i for every positive argument ii. Next we show that f(i)=i1f(i) = i-1 whenever ff is regular and i1i-1 occurs among the values of ff. Indeed, let kk be the least positive integer such that f(k)=i1f(k) = i-1; by the above, kik \ge i. By regularity, i1i-1 occurs in the sequence k1,f(k1),f(f(k1)),k-1, f(k-1), f(f(k-1)), \dots. If i1=k1i-1 = k-1 then f(i)=i1f(i) = i-1, otherwise i1i-1 can be represented in the form f(j)f(j) where jk1<kj \le k-1 < k, which contradicts the choice of kk.

Now we prove by induction on nn that the information given to Miku by Juku uniquely determines the regular function. For n=0n=0, there exists only one regular function, whence the claim holds. Assume in the following that n>0n > 0 and the claim holds for n1n - 1. Let a0,a1,,ana_0, a_1, \dots, a_n be the numbers of repetitions of values of ff. By the property proven at the beginning of the solution, nn cannot occur among the values of ff, hence an=0a_n = 0. Let ll be the least positive integer such that al=0a_l = 0. As al1>0a_{l-1} > 0, we have f(l)=l1f(l) = l - 1 by the above. Define b0,b1,,bn1b_0, b_1, \dots, b_{n-1} by
bi={ai,if i<l1,ai1,if i=l1,ai+1,if il. b_i = \begin{cases} a_i, & \text{if } i < l - 1, \\ a_i - 1, & \text{if } i = l - 1, \\ a_{i+1}, & \text{if } i \ge l. \end{cases}
Note that b0,b1,,bn1b_0, b_1, \dots, b_{n-1} are the numbers of repetitions of values of function gg defined by
g(i)={f(i),if i<l,f(i+1),if f(i+1)<li,f(i+1)1,if l<f(i+1). g(i) = \begin{cases} f(i), & \text{if } i < l, \\ f(i+1), & \text{if } f(i+1) < l \le i, \\ f(i+1) - 1, & \text{if } l < f(i+1). \end{cases}
In other words, function gg is obtained from ff by removing the argument-value pair (l,l1)(l, l-1) (this removes the only occurrence of ll in these pairs) and decreasing the numbers l+1,,nl+1, \dots, n by 1 in all other pairs. It is easy to check that regularity of ff implies regularity of gg. By the induction hypothesis, gg is the only regular function with numbers of repetitions of values are b0,b1,,bn1b_0, b_1, \dots, b_{n-1}. But ff can be defined in terms of gg:
f(i)={g(i),if i<l,l1,if i=l,g(i1),if g(i1)<l<i,g(i1)+1,if lg(i1). f(i) = \begin{cases} g(i), & \text{if } i < l, \\ l-1, & \text{if } i = l, \\ g(i-1), & \text{if } g(i-1) < l < i, \\ g(i-1)+1, & \text{if } l \le g(i-1). \end{cases}
In other words, add the argument-value pair (l,l1)(l, l-1) and increase all numbers l,,n1l, \dots, n-1 by 1 in other pairs. This completes the solution.

Want a route through all this instead of an archive? The track puts 2,000 problems in a working order, from AMC 10 level to the IMO shortlist.

Source: MathNet, licensed CC-BY-4.0. Statement and solution reproduced as published; topic and difficulty added by this site.