\(\sqrt{x+2017}-y^3=\sqrt{y+2017}-x^3\)
\(\Leftrightarrow\left(\sqrt{x+2017}-\sqrt{y+2017}\right)+\left(x^3-y^3\right)=0\)
\(\Leftrightarrow\dfrac{x-y}{\sqrt{x+2017}+\sqrt{y+2017}}+\left(x-y\right)\left(x^2+xy+y^2\right)=0\)
\(\Leftrightarrow\left(x-y\right)\left(\dfrac{1}{\sqrt{x+2017}+\sqrt{y+2017}}+\left(x^2+xy+y^2\right)\right)=0\)
\(\Leftrightarrow x=y\)
\(\Rightarrow P=x^2-3x^2+12x-x^2+2018\)
\(=-3x^2+12x+2018=2030-3\left(x-2\right)^2\le2030\)