Lemma. Let x,y,z be integers with 1≤x,y,z≤N. Then at least one of (x,y,z), (y,z,x), or (z,x,y) belongs to S.
proof. Consider a sequence a1=x,a2=y,a3=z,a4=x,a5=y,a6=z,…. Then, for every positive integer i, (ai,ai+1,ai+2) is one of (x,y,z), (y,z,x), or (z,x,y). Therefore, by the assumption of the problem, at least one of these triples must belong to S. ■
Consider the set
X={(x1,y1,z1),(x2,y2,z2),…,(xn,yn,zn),(y1,z1,x1),(y2,z2,x2),…,(yn,zn,xn),(z1,x1,y1),(z2,x2,y2),…,(zn,xn,yn)}.
Let p,q,r be integers with 1≤p,q,r≤N. Applying Lemma to (x,y,z)=(p,q,r), it follows that at least one of (p,q,r), (q,r,p), or (r,p,q) belongs to S, say it is (xj,yj,zj) for some 1≤j≤n. Then, (p,q,r) is equal to one of (xj,yj,zj), (zj,xj,yj), or (yj,zj,xj), and therefore, (p,q,r) belongs to X. Thus, it has been shown that X is the set of all N3 triples (p,q,r) with 1≤p,q,r≤N.
By applying Lemma to (x,y,z)=(1,1,1),(2,2,2),…,(N,N,N), we find that these triples (1,1,1),(2,2,2),…,(N,N,N) all belong to S. If (xj,yj,zj) is equal to one of them, we have (xj,yj,zj)=(yj,zj,xj)=(zj,xj,yj), hence the number of elements of X is less than or equal to 3n−2N. Therefore we have 3n−2N≥N3, thus n≥3N3+2N.
Next, we construct a set S satisfying n=3N3+2N. Define S to be the set of triples (x,y,z) with 1≤x,y,z≤N such that either
* x>y and x≥z, or
∙x=y=z.
If we fix an integer x with 1≤x≤N, the number of pairs (y,z) such that (x,y,z) belongs to S is equal to x(x−1)+1. Therefore, the number of elements in S, denoted by n, is
n=x=1∑N(x(x−1)+1)=3N3+2N.
Assume, for the sake of contradiction, that there exists a sequence a1,a2,… of integers 1,2,…,N such that none of the triples (a1,a2,a3),(a2,a3,a4),… belongs to S. Let ak be one of the largest terms among a1,a2,…. Then we have ak≥ak+1 and ak≥ak+2. Since (ak,ak+1,ak+2) does not belong to S, we have ak+1=ak. Therefore, ak+1 is also one of the largest terms in the sequence. Applying the same argument to (ak+1,ak+2,ak+3), we obtain ak+2=ak+1. Hence, ak=ak+1=ak+2, so (ak,ak+1,ak+2) belongs to S, a contradiction. Therefore, this set S satisfies the required condition.
This shows that the minimum value of n is 3N3+2N=333400.