Unofficial archive — problems, solutions & results © IMC, reproduced with permission.

IMC / 2020 / Problems / Day 1, P1

IMC 2020 · Day 1 · P1

easy

Let nn be a positive integer. Compute the number of words ww (finite sequences of letters) that satisfy all the following three properties:

(1) ww consists of nn letters, all of them are from the alphabet {a,b,c,d}\{a, b, c, d\};

(2) ww contains an even number of letters aa;

(3) ww contains an even number of letters bb.

(For example, for n=2n = 2 there are 6 such words: aaaa, bbbb, cccc, dddd, cdcd and dcdc.)

Armend Sh. Shabani, University of Prishtina

Solution 1 of 3 (official)

Let N={1,2,,n}N = \{1, 2, \dots, n\}. Consider a word ww that satisfies the conditions and let A,B,C,DNA, B, C, D \subset N be the sets of positions of letters aa, bb, cc and dd in ww, respectively. By the definition of the words we have ABCD=NA \sqcup B \sqcup C \sqcup D = N. The sets AA and BB are constrained to have even sizes.

In order to construct all suitable words ww, choose the set S=ABS = A \cup B first; by the conditions, S=A+B|S| = |A| + |B| must be even. It is well-known that an nn-element set (with n1n \ge 1) has 2n12^{n-1} even subsets, so there are 2n12^{n-1} possibilities for SS.

If S=S = \emptyset then we can choose CNC \subset N arbitrarily, and then the set D=SCD = S \setminus C is determined uniquely. Since NN has 2n2^n subsets, we have 2n2^n options for set CC and therefore 2n2^n suitable words ww with S=S = \emptyset.

Otherwise, if k=S>0k = |S| > 0, we have to choose an arbitrary subset CC of NSN \setminus S and an even subset AA of SS; then D=(NS)CD = (N \setminus S) \setminus C and B=SAB = S \setminus A are determined and B=SA|B| = |S| - |A| will automatically be even. We have 2nk2^{n-k} choices for CC and 2k12^{k-1} independent choices for AA; so for each nonempty even SS we have 2nk2k1=2n12^{n-k} \cdot 2^{k-1} = 2^{n-1} suitable words.

The number of nonempty even sets SS is 2n112^{n-1} - 1, so in total, the number of words satisfying the conditions is 12n+(2n11)2n1=4n1+2n1.1 \cdot 2^n + (2^{n-1} - 1) \cdot 2^{n-1} = 4^{n-1} + 2^{n-1}.

Solution 2 of 3 (official)

Let ana_n denote the number of words of length nn over A={a,b,c,d}\mathcal{A} = \{a, b, c, d\} such that aa and bb appear even number of times. Further, we define the following sequences for the number of words of length nn, all over A\mathcal{A}.

  • bnb_n - the number of words with an odd number of aa's and even number of bb's
  • cnc_n - the number of words with even number of aa's and an odd number of bb's
  • dnd_n - the number of words with an odd number of aa's and an odd number of bb's
We will call them AA-words, BB-words, CC-words and DD-words, respectively.

It is clear that a1=2a_1 = 2 and that an+bn+cn+dn=4n.a_n + b_n + c_n + d_n = 4^n. First, we find a recurrence relation for ana_n. If an AA-word of length nn begins with cc or dd, it can be followed by any AA-word of length n1n - 1, contributing with 2an12 a_{n-1}. If an AA-word of length nn begins with aa, it can be followed by any word of length n1n - 1 that contains an odd number of aa's and even number of bb's, thus contributing with bn1b_{n-1}. If an AA-word of length nn begins with bb, it can be followed by any word of length n1n - 1 that contains even number of aa's and an odd number of bb's, thus contributing with cn1c_{n-1}. Therefore we have the following recurrence relation: an=2an1+bn1+cn1.(1)\tag{1} a_n = 2 a_{n-1} + b_{n-1} + c_{n-1}. Next, we find a recurrence relation for bnb_n.

If a BB-word of length nn begins with cc or dd, it can be followed by any BB-word of length n1n - 1, contributing with 2bn12 b_{n-1}. If a BB-word of length nn begins with aa, it can be followed by any word of length n1n - 1 that contains even number of aa's and even number of bb's, contributing with an1a_{n-1}. If a BB-word of length nn begins with bb, it can be followed by any word of length n1n - 1 that contains an odd number of aa's and an odd number of bb's, contributing with dn1=4n1an1bn1cn1d_{n-1} = 4^{n-1} - a_{n-1} - b_{n-1} - c_{n-1}. Therefore we have the following recurrence relation: bn=bn1+4n1cn1.(2)\tag{2} b_n = b_{n-1} + 4^{n-1} - c_{n-1}. Now observe that bk=ckb_k = c_k for all kk, since simultaneously replacing aa's to bb's and vice versa we get a CC-word from a BB-word. Therefore (2) yields bn=4n1b_n = 4^{n-1}. Now (1) yields an=2an1+24n2.a_n = 2 \cdot a_{n-1} + 2 \cdot 4^{n-2}. Solving the last recurrence relation (for example, diving by 2n2^n we get xn:=an2nx_n := a_n 2^{-n} satisfies xnxn1=2n3x_n - x_{n-1} = 2^{n-3}, and it remains to sum up consecutive powers of 2) we get an=2n1+4n1.a_n = 2^{n-1} + 4^{n-1}.

Solution 3 of 3 (official)

Consider the sum (a+b+c+d)n+(ab+c+d)n+(a+b+c+d)n+(ab+c+d)n4.()\tag{$*$} \frac{(a+b+c+d)^n + (-a-b+c+d)^n + (-a+b+c+d)^n + (a-b+c+d)^n}{4}. Expanding the parentheses as (a+b+c+d)n=(a+b+c+d)(a+b+c+d)(a+b+c+d),(a+b+c+d)^n = (a+b+c+d)(a+b+c+d) \dots (a+b+c+d), we get a sum of products x1xnx_1 \dots x_n, xi{a,b,c,d}x_i \in \{a, b, c, d\}, naturally corresponding to the words of length nn over the alphabet {a,b,c,d}\{a, b, c, d\}. Consider the other terms in the numerator similarly.

If a word x1xnx_1 \dots x_n contains A,B,C,DA, B, C, D letters a,b,ca, b, c and dd respectively, we get aAbBcCdDa^A b^B c^C d^D with the coefficient 1+(1)A+B+(1)A+(1)B4=(1+(1)A)(1+(1)B)4={1,if A and B are even0,otherwise.\frac{1 + (-1)^{A+B} + (-1)^A + (-1)^B}{4} = \frac{(1 + (-1)^A)(1 + (-1)^B)}{4} = \begin{cases} 1, & \text{if } A \text{ and } B \text{ are even} \\ 0, & \text{otherwise.} \end{cases} Hence, by substituting a=b=c=d=1a = b = c = d = 1 in ()(*) we get the answer (4n+2n+1)/4=4n1+2n1(4^n + 2^{n+1}) / 4 = 4^{n-1} + 2^{n-1}.

How the field did

contestants scored
453
average (of 10)
7.66
solved (≥ 80%)
69.8%
near-0 (≤ 10%)
10.6%
discrimination
0.29

Score distribution (field cohort)

Computed on contestants with a meaningful total (field cohort); discrimination is the corrected item–total correlation.

Similar problems

IMC 2005 · Day 1 · P2easyavg 7.0/10 · solved 67% · near-0 23% · disc 0.57
IMC 2002 · Day 2 · P8easyavg 8.0/10 · solved 76% · near-0 14% · disc 0.47
IMC 2024 · Day 2 · P6easyavg 8.2/10 · solved 77% · near-0 11% · disc 0.35
IMC 2014 · Day 2 · P6easyavg 8.6/10 · solved 86% · near-0 12% · disc 0.38