$M=X\cup Y$. If $S\subset M$ is open in $S\cup X$ and open in $S\cup Y$ then $S$ is open in $M$. 
Let $M=X\cup Y$ be a metric space. If $S\subset M$ is open in $S\cup X$ and open in $S\cup Y$ then $S$ is open in $M$.

I can't do anything with this exercise. I think that is the hardest problem in my book.
 A: Since $S$ is open in $S\cup X$, there must be an open set $U$ in $X$ such that $U\cap(S\cup X)=S$. Similarly, since $S$ is open in $S\cup Y$, there must be an open set $V$ in $X$ such that $V\cap(S\cup Y)=S$. Clearly $S\subseteq U$, so $U\cap S = S$, and $$S=U\cap(S\cup X)=(U\cap S)\cup(U\cap X)=S\cup(U\cap X)\;,$$ and therefore $U\cap X\subseteq S$. Similarly, $S\subseteq V$, so $$S=V\cap(S\cup Y)=(V\cap S)\cup(V\cap Y)=S\cup(V\cap Y)\;,$$ and therefore $V\cap Y\subseteq S$. 
Next, note that $S\subseteq U\cap V$; $U\cap V$ is open in $M$, so we’re done if we can show that $S=U\cap V$. We know that $U\cap X\subseteq S$, so certainly $U\cap V\cap X\subseteq S$. Similarly, from $V\cap Y\subseteq S$ we can infer that $U\cap V\cap Y\subseteq S$. But then 
$$\begin{align*}
U\cap V&=(U\cap V)\cap M\\
&=(U\cap V)\cap(X\cup Y)\\
&=(U\cap V\cap X)\cup(U\cap V\cap Y)\\
&\subseteq S\;,
\end{align*}$$
so indeed $U\cap V=S$.
As you can see, the result is valid for topological spaces in general, not just for metric spaces.
