Are functions that map dense sets to dense sets continuous?

Suppose $X$ and $Y$ are separable metric spaces, and that $f:X\rightarrow Y$ is a bijective function that maps every countable dense set of $X$ to a dense set of $Y$.

Are functions with this property necessarily continuous?

If not, if $g:X\rightarrow Y$ is bijective and Borel do we obtain that property (dense sets map to dense sets)?

Thanks for any information.

Consider the function $f: \mathbb R \rightarrow \mathbb R$ defined by
$$f(x)=\begin{cases}x & x\neq 1,2 \\ 2 &x=1\\ 1 &x=2\end{cases}.$$
That is $f$ is the identity except it swaps $1$ and $2$. Then $f$ is Borel and bijective and maps countable dense sets to countable dense sets, since if $D \subset \mathbb R$ is a dense subset and $x \in D$ then $D\setminus \{x\}$ is also dense.
Edit: I misread your second question. I think we can make a map that messes with the rationals and is still Borel. Let $g: \mathbb R \rightarrow \mathbb R$ be the identity on the irrationals. Let $g$ map the negative rationals to themselves and let $g$ send $\mathbb N$ to the positive non-integer rationals and send the positive non-integer rationals to $\mathbb N$. Then $g$ should still be Borel, but $\mathbb Q \setminus \mathbb N$ is a countable dense subset whose image is not dense under $g$.
• @Robert, A similar construction will work. Let $A=\{1/2n : n \in \mathbb N$ and $B=\{1/(2n+1) : n \in \mathbb N\}$ send $\mathbb Q \cap [0,1] \setminus (A \cup B)$ to $A$ and send $A \cup B$ to $B$. You can check this is still Borel and bijective. This does not contradict Lusin's theorem, notice we can cover the rationals by arbitrarily small open sets. – JSchlather Feb 5 '13 at 8:36