prove that a function and its inverse are both continuous 
Let $f : \mathbb{R}^n\to \mathbb{R}^n$ be bijective. Suppose $f$ maps connected sets to connected sets and that $f$ maps disconnected sets to disconnected sets. Prove that $f$ and $f^{-1}$ are both continuous.

Observe that $f^{-1}$ sends connected sets to connected sets because for a connected set $B\subseteq \mathbb{R}^n$, if $f^{-1}(B)$ was disconnected then $f(f^{-1}(B)) = B$ would be disconnected, contradicting the fact that $B$ is connected. Similarly, $f^{-1}$ sends disconnected sets to disconnected sets. So it suffices to show that $f$ is continuous. Would it be sufficient to show that $f^{-1}(B)$ is open for every open ball $B$ in $\mathbb{R}^n$ and if so, why? I'm pretty sure this needs to be done for an arbitrary open set.
Also, it seems true (and may be useful for this problem) that if $C$ is a connected set and $c\in \overline{C}$, then $D=\{c\}\cup C$ is connected.
Proof. If $c\in C$, this is trivial so suppose $c\not\in C$. Suppose also that $D$ is disconnected. Then there exist two nonempty disjoint open sets $U$ and $V$ so that $D \subseteq U\cup V, V\cap D\neq \emptyset, U\cap D\neq \emptyset, U\cap V = \emptyset$. In particular, $c\in U$ or $c\in V$. WLOG, suppose $c\in U$. Observe that $U\backslash \{c\}$ is open and nonempty. So we have $C \subseteq U\backslash \{c\} \cup V, U\backslash \{c\} \cap V = \emptyset, V\neq \emptyset, U\backslash \{c\}\neq \emptyset.$ Since $c\in \overline{C}$ and $c\in U$, we claim that $U\backslash \{c\} \cap C\neq \emptyset$, which will prove the result because $C\cap V = D\cap V \neq \emptyset$. Since $c\in U, \exists r > 0$ so that $B_r(c)\subseteq U$, where $B_r(c)$ is the open ball centered at $c$ of radius $r$. But since $c\in \overline{C}$, we can find a sequence $(x_n)$ in $C$ converging to $c$, and so for sufficiently large $n, x_n \in B_r(c)\backslash \{c\}$ (since $c\not\in C$ by assumption). So $x_n\in U\backslash \{c\}\cap C$ for sufficiently large $n$.
 A: This mostly looks good, but I noticed a few problems. I'll point them out below; please note this answer does not provide a proof of the quoted statement!

Observe that $f^{-1}$ sends connected sets to connected sets because for a connected set $B\subseteq \mathbb{R}^n$, if $f^{-1}(B)$ was disconnected then $f(f^{-1}(B)) = B$ would be disconnected, contradicting the fact that $f$ sends connected sets to connected sets.

You did not contradict the fact that $f$ sends connected sets to connected sets. You contradicted the assumption that $B$ is connected.

So it suffices to show that $f$ is continuous.

No, before you can say this, you first need to show that $f^{-1}$ sends disconnected sets to disconnected sets.

Would it be sufficient to show that $f^{-1}(B)$ is open for every open ball $B$ in $\mathbb{R}^n$ and if so, why? I'm pretty sure this needs to be done for an arbitrary open set.

Yes, this is sufficient. You're right that the definition of continuity says that the inverse image of every open set must be open, but since every open set is a union of open balls, it is equivalent to show that the inverse image of every open ball is open. I think it's important to work through the details yourself.

Then there exist two nonempty disjoint open sets $U$ and $V$ so that $D \subseteq U\cup V, U\cap D\neq \emptyset, U\cap V\neq \emptyset$.

Typo? This should say $U \cap V = \varnothing$.
