3. 2.5 * In the sequence $\left\{a_{n}\right\}$, $a_{1}=1, a_{n+1}=3 a_{n}-2 n^{2}+4 n+4, n=1,2, \cdots$. Find the general term of the sequence $\left\{a_{n}\right\}$.
The difficulty of this problem lies in the recursive relationship changing with the variation of $n$. We construct a sequence related to $\left\{a_{n}\right\}$ that can be solved for its general term. Let
$$
a_{n+1}-\left[x_{1}(n+1)^{2}+x_{2}(n+1)+x_{3}\right]=3\left[a_{n}-\left(x_{1} n^{2}+x_{2} n+x_{3}\right)\right] \text {, }
$$

By comparing it with the given recursive relationship, we get $\left\{\begin{array}{l}x_{1}-3 x_{1}=-2, \\ 2 x_{1}+x_{2}-3 x_{2}=4, \\ x_{1}+x_{2}+x_{3}-3 x_{3}=4,\end{array}\right.$ Solving this system of equations yields $x_{1}=1, x_{2}=-1, x_{3}=-2$. Therefore,
$$
a_{n+1}-\left[(n+1)^{2}-(n+1)-2\right]=3\left[a_{n}-\left(n^{2}-n-2\right)\right] .
$$

Thus, the sequence $\left\{a_{n}-n^{2}+n+2\right\}$ is a geometric sequence with the first term $a_{1}-1^{2}+1+2=3$ and common ratio 3, hence $a_{n}-n^{2}+n+2=3 \cdot 3^{n-1}=3^{n}$, which means $a_{n}=3^{n}+n^{2}-n-2$.