II. (50 points) Let $a_{1}, a_{2}, \cdots, a_{2009}$ be non-negative real numbers, satisfying the following conditions:
(1) $a_{1}+a_{2}+\cdots+a_{2009}=2$;
(2) $a_{1} a_{2}+a_{2} a_{3}+\cdots+a_{2008} a_{2009}+a_{2009} a_{1}=$
1.

Find the maximum and minimum values of $S=a_{1}^{2}+a_{2}^{2}+\cdots+a_{2009}^{2}$.
Let's assume $a_{2009}$ is the smallest among these $a_{i}$, and $a_{1} > 0$. From the given information, we have:
$$
\begin{array}{c}
4=\left(a_{1}+a_{2}+\cdots+a_{2009}\right)^{2} \geqslant\left(a_{1}+a_{2}+\cdots+\right. \\
\left.a_{2009}\right)^{2}-\left(a_{1}-a_{2}+a_{3}-\cdots-a_{2008}+a_{2009}\right)^{2} \\
=4\left(a_{1}+a_{3}+\cdots+a_{2009}\right)\left(a_{2}+a_{4}+\cdots+a_{2008}\right) \\
\geqslant 4\left(a_{1} a_{2}+a_{2} a_{3}+\cdots+a_{2008} a_{2009}\right)+4\left(a_{1} a_{4}+\right. \\
\left.a_{2} a_{5}+\cdots+a_{2006} a_{2009}\right) \\
\quad+4 a_{1}\left(a_{6}+a_{8}+\cdots+a_{2008}\right) \\
\quad=4\left(1-a_{1999} a_{1}\right)+4\left(a_{1} a_{4}+a_{2} a_{5}+\cdots+a_{2006} a_{2009}\right)+ \\
4 a_{1}\left(a_{6}+a_{8}+\cdots+a_{2008}\right) \\
\quad=4+4\left(a_{1} a_{4}+a_{2} a_{5}+\cdots+a_{306} a_{2009}\right)+4 a_{1}\left(a_{6}+a_{8}+\right. \\
\left.\cdots+a_{2008}-a_{2009}\right) \geqslant 4,
\end{array}
$$

Therefore, the equality must hold in the first and third inequalities, which implies:
(1) $a_{1}+a_{3}+\cdots+a_{2009}=a_{2}+a_{4}+\cdots+a_{2008}=1$
(2) $a_{1} a_{4}=a_{2} a_{5}=\cdots=a_{2006} a_{2009}=0$
(3) $a_{6}+a_{8}+\cdots+a_{2008}=a_{2009}$
Condition (2) indicates that $a_{4}=0=a_{2009}$; from (3) we get $a_{6}=a_{8}=\cdots=a_{2008}=0$, and from (1) we have $a_{2}=1$,

From (2), we get $a_{1}+a_{3}=1$, and from condition (1) we have $a_{4}+a_{5}+\cdots+a_{2009}=0$, i.e., $a_{4}=a_{5}=\cdots=a_{2009}=0$,

Therefore, $S=a_{1}^{2}+a_{2}^{2}+a_{3}^{2}=a_{1}^{2}+1+\left(1-a_{1}\right)^{2}=$ $2\left(a_{1}^{2}-a_{1}+1\right)=2\left(a_{1}-\frac{1}{2}\right)^{2}+\frac{3}{2}$.

Thus, when $a_{1}=1$, $S$ has a maximum value of 2, and when $a_{1}=\frac{1}{2}$, it has a minimum value of $\frac{3}{2}$.