II. (50 points) Let $a_{1}, a_{2}, \cdots, a_{2009}$ be non-negative real numbers, satisfying:
(1) $a_{1}+a_{2}+\cdots+a_{2009}=2$;
(2) $a_{1} a_{2}+a_{2} a_{3}+\cdots+a_{208} 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{aligned}
4= & \left(a_{1}+a_{2}+\cdots+a_{2009}\right)^{2} \\
\geqslant & \left(a_{1}+a_{2}+\cdots+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}+a_{2} a_{5}+\cdots+a_{2006} a_{2009}\right)+ \\
& 4 a_{1}\left(a_{6}+a_{8}+\cdots+a_{2008}\right) \\
= & 4\left(1-a_{2009} a_{1}\right)+4\left(a_{1} a_{4}+a_{2} a_{5}+\cdots+\right. \\
& \left.a_{2006} a_{2009}\right)+4 a_{1}\left(a_{6}+a_{8}+\cdots+a_{2008}\right) \\
= & 4+4\left(a_{1} a_{4}+a_{2} a_{5}+\cdots+a_{2006} a_{2009}\right)+
\end{aligned}
$$
$$
4 a_{1}\left(a_{6}+a_{8}+\cdots+a_{2008}-a_{2009}\right)
$$
$\geqslant 4$.
Therefore, the equality must hold in the first and third inequalities. Thus, we must have
$$
\begin{array}{l}
\text { (i) } a_{1}+a_{3}+\cdots+a_{2009} \\
=a_{2}+a_{4}+\cdots+a_{2008}=1 ;
\end{array}
$$
(ii) $a_{1} a_{4}=a_{2} a_{5}=\cdots=a_{2006} a_{2009}=0$;
(iii) $a_{6}+a_{8}+\cdots+a_{2008}=a_{2009}$.
(ii) indicates that $a_{4}=0=a_{2009}$.

From (iii), we get $a_{6}=a_{8}=\cdots=a_{2008}=0$.
From (i), we get $a_{2}=1$.
From condition (2), we get $a_{1}+a_{3}=1$,
From condition (1), we get $a_{4}+a_{5}+\cdots+a_{2009}=0$, i.e., $a_{4}=a_{5}=\cdots=a_{2009}=0$.
Thus, $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} \text {. }
$$

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