\(x^2-x+2-3x-7=0\\ \Leftrightarrow x^2-4x-5=0\\ \Leftrightarrow x^2+x-5x-5=0\\ \Leftrightarrow x\left(x+1\right)-5\left(x+1\right)=0\\ \Leftrightarrow\left(x+1\right)\left(x-5\right)=0\\ \Leftrightarrow\left[{}\begin{matrix}x+1=0\\x-5=0\end{matrix}\right.\Leftrightarrow\left[{}\begin{matrix}x=-1\\x=5\end{matrix}\right.\)
Vạy \(S=\left\{-1;5\right\}\)