In Y the only closed sets are Y and the empty set. All others are open.

Do you know the open/closed set formulation of continuity? It says that if the preimage of open (closed) sets are open (closed), then f is continuous.

If you can show that the preimages of Y and the empty set are closed, then you are done.