Define the function $S: \mathbf{C} \rightarrow \mathbf{C}$ as
$$
S(z)=\left\{\begin{array}{ll}
z, & \operatorname{Re} z \geqslant 0 ; \\
-z, & \operatorname{Re} z<0 .
\end{array}\right.
$$

For a given complex number $r$, define the infinite sequence of complex numbers $\left\{z_{n}\right\}$ such that
$$
z_{1}=r, z_{n+1}=S\left(z_{n}^{2}+z_{n}+1\right) .
$$

Find all complex numbers $r$ such that $\left\{z_{n}\right\}$ is a periodic sequence.
Let $a_{n}=\operatorname{Re} z_{n}, b_{n}=\operatorname{Im} z_{n}$.
It is easy to see that for all $n \in \mathbf{Z}_{+}$, we have $a_{n} \geqslant 0$.
From the given, we have
$$
\left\{\begin{array}{l}
a_{n+1}=\left|a_{n}^{2}+a_{n}+1-b_{n}^{2}\right|, \\
\left|b_{n+1}\right|=\left|b_{n}\left(2 a_{n}+1\right)\right| .
\end{array}\right.
$$

Construct a function $f: \mathbf{R}_{+} \times \mathbf{R} \rightarrow \mathbf{R}$,
$$
\begin{array}{l} 
f(a, b)=2 a^{2}+b^{2} . \\
\text { Then } f\left(a_{n+1}, b_{n+1}\right)-f\left(a_{n}, b_{n}\right) \\
= 2\left(a_{n}^{2}+a_{n}+1-b_{n}^{2}\right)^{2}+b_{n}^{2}\left(2 a_{n}+1\right)^{2}- \\
2 a_{n}^{2}-b_{n}^{2} \\
= 2\left[\left(a_{n}^{2}+a_{n}\right)+\left(1-b_{n}^{2}\right)^{2}\right]+ \\
4 b_{n}^{2}\left(a_{n}^{2}+a_{n}\right)-2 a_{n}^{2} \\
= 2\left[\left(a_{n}^{2}+a_{n}\right)^{2}+\left(b_{n}^{2}-1\right)^{2}+a_{n}^{2}+2 a_{n}\right] \\
\geqslant 0 .
\end{array}
$$

Equality holds if and only if $a_{n}=0$ and $b_{n} \in\{1,-1\}$.
(1) If $r \in\{\mathrm{i},-\mathrm{i}\}$, then $\left\{z_{n}\right\}$ is a constant sequence.
Thus, $r= \pm \mathrm{i}$ satisfies the requirement.
(2) If $r \notin\{\mathrm{i},-\mathrm{i}\}$, we will prove by induction on the sequence: for any $n \in \mathbf{Z}_{+}$,
$$
\left(a_{n}, b_{n}\right) \notin\{(0,1),(0,-1)\} \text {. }
$$

When $n=1$, since $r \notin\{\mathrm{i},-\mathrm{i}\}$, we have
$$
\left(a_{1}, b_{1}\right) \notin\{(0,1),(0,-1)\} \text {. }
$$

Assume that for $n=k$,
$$
\left(a_{k}, b_{k}\right) \notin\{(0,1),(0,-1)\} \text {. }
$$

When $n=k+1$, if
$$
\left(a_{k+1}, b_{k+1}\right) \in\{(0,1),(0,-1)\} \text {, }
$$

then $a_{k+1}=0$.
Thus, $a_{k}^{2}+a_{k}+1-b_{k}^{2}=0$.
Since $a_{k}>0$, we have $b_{k}^{2}>1$.
Then $\left|b_{k+1}\right|=\left|b_{k}\right|\left|2 a_{k}+1\right|>1$, which is a contradiction.
Hence, $\left(a_{k+1}, b_{k+1}\right) \notin\{(0,1),(0,-1)\}$.
Therefore, for any $n \in \mathbf{Z}_{+}$,
$$
\left(a_{n}, b_{n}\right) \notin\{(0,1),(0,-1)\} \text {. }
$$

Thus, $f\left(a_{n}, b_{n}\right)$ is strictly increasing.
Therefore, $\left\{\left(a_{n}, b_{n}\right)\right\}$ cannot be a periodic sequence.
In conclusion, $r= \pm \mathrm{i}$.
(Li Zhaohui, Fudan University High School, 200433)