Solution (source code)

= Solution

If a nonempty subset $S\subset\mathbb R$ is not an interval, there are $a,b\in S$ and $c\notin S$ with $a<c<b$. The disjoint nonempty relatively open sets $S\cap(-\infty,c)$ and $S\cap(c,\infty)$ form a separation, so $S$ is not <connected>.

Conversely, suppose an interval $I$ had a separation into relatively open nonempty sets $A,B$. Choose $a\in A,b\in B$, interchanging the names if necessary so $a<b$. Put $c=\sup(A\cap[a,b])$. Because $B$ contains a relative neighbourhood of $b$, $c<b$; because $A$ contains a relative neighbourhood of $a$, $c>a$. Also $c\in[a,b]\subset I$. If $c\in A$, relative openness supplies points of $A$ just above $c$, contradicting the <supremum>. If $c\in B$, a relative neighbourhood of $c$ excludes points of $A$ approaching $c$ from below, again contradicting the <supremum>. Thus every interval is <connected>, including a singleton and unbounded or open intervals.

Take
$$
\boxed{K=\{0\}\cup\{1/n:n\ge1\}}.
$$
It is closed, because its only accumulation point is $0$ and that point is included, and bounded. The <Heine-Borel theorem> makes it <compact>. The <connected components> of its complement are precisely
$$
(-\infty,0),\quad(1,\infty),\quad\left(\frac1{n+1},\frac1n\right)\quad(n\ge1).
$$
Each is an interval and therefore <connected>; none can be enlarged inside the complement across one of the intervening points of $K$.