The required polynomials are all polynomials of an even degree d≥2, and all polynomials of odd degree d≥3 with a negative leading coefficient.
Part I. We begin by showing that any (non-constant) polynomial S(x) not listed above is not (A,B)-nice for some pair (A,B) with either ∣A∣=∣B∣=2, or ∣A∣=∣B∣=3.
If S(x) is linear, then so are all the polynomials appearing on the board. Therefore, none of them will be (A,B)-nice, say, for A={1,2,3} and B={1,2,4}, as desired.
Otherwise, degS=d≥3 is odd, and the leading coefficient is positive. In this case, we make use of the following technical fact, whose proof is presented at the end of the solution.
Claim. There exists a positive constant T such that S(x) satisfies the following condition:
S(b)−S(a)≥b−a whenever b−a≥T
Fix a constant T provided by the Claim. Then, an immediate check shows that all newly appearing polynomials on the board also satisfy (∗) (with the same value of T ). Therefore, none of them will be (A,B)-nice, say, for A={0,T} and B={0,T/2}, as desired.
Part II. We show that the polynomials listed in the Answer satisfy the requirements. We will show that for any a1maxx∈ΔS(x). Therefore, for any x,y,z with x≤α≤y≤β≤z we get S(x)≤S(α)≤ S(y)≤S(β)≤S(z).
We may decrease α and increase β (preserving the condition above) so that, in addition, S′(x)>3 for all x∈/[α,β]. Now we claim that the number T=3(β−α) fits the bill.
Indeed, take any a and b with b−a≥T. Even if the segment [a,b] crosses [α,β], there still is a segment [a′,b′]⊆[a,b]\(α,β) of length b′−a′≥(b−a)/3. Then
S(b)−S(a)≥S(b′)−S(a′)=(b′−a′)⋅S′(ξ)≥3(b′−a′)≥b−a
for some ξ∈(a′,b′).
Proof of Lemma 1. If S(x) has an even degree, then the polynomial T(x)=S(x+a2)−S(x+a1) has an odd degree, hence there exists x0 with T(x0)=S(x0+a2)−S(x0+a1)=b2−b1. Setting G(x)=S(x+x0), we see that G(a2)−G(a1)=b2−b1, so a suitable shift F(x)=G(x)+(b1−G(a1)) fits the bill.
Assume now that S(x) has odd degree and a negative leading coefficient. Notice that the polynomial S2(x):=S(S(x)) has an odd degree and a positive leading coefficient. So, the polynomial S2(x+a2)−S2(x+a1) attains all sufficiently large positive values, while S(x+a2)− S(x+a1) attains all sufficiently large negative values. Therefore, the two-variable polynomial S2(x+a2)−S2(x+a1)+S(y+a2)−S(y+a1) attains all real values; in particular, there exist x0 and y0 with S2(x0+a2)+S(y0+a2)−S2(x0+a1)−S(y0+a1)=b2−b1. Setting G(x)=S2(x+x0)+S(x+y0), we see that G(a2)−G(a1)=b2−b1, so a suitable shift of G fits the bill.
Proof of Lemma 2. Let Δ denote the segment [a1;an]. We modify the proof of Lemma 1 in order to obtain a polynomial F convex (or concave) on Δ such that F(a1)=F(a2); then F is a desired polynomial. Say that a polynomial H(x) is good if H is convex on Δ.
If degS is even, and its leading coefficient is positive, then S(x+c) is good for all sufficiently large negative c, and S(a2+c)−S(a1+c) attains all sufficiently large negative values for such c. Similarly, S(x+c) is good for all sufficiently large positive c, and S(a2+c)−S(a1+c) attains all sufficiently large positive values for such c. Therefore, there exist large $c_{1}T \quad \text { whenever } \quad b-a>T
Let us sketch an alternative approach for Part II. It suffices to construct, for each i, a polynomial fi(x) such that fi(ai)=bi and fi(aj)=0,j=i. The construction of such polynomials may be reduced to the construction of those for n=3 similarly to what happens in the proof of Lemma 2. However, this approach (as well as any in this part) needs some care in order to work properly.