Let $f: X \rightarrow Y$ be a function.
Let $A, B$ are closed subets of $X$ such that $X = A \cup V$. Then $f$ is continuous iff
$f|_A$ and $f|_B$ are continous.

This is clear from how restrictions work. Pick $i: A \rightarrow X$ to be the
function that embeds $A$ with the subspace topology into $X$. This is continuous by
the definition of the subspace topology. Now define $f|_A : A \rightarrow Y \equiv f \circ i$.
which is continous since it is the composition of continuous functions.

Let $V \subseteq Y$ be closed. Then $f_A^{-1}(V)$ is closed in $A$ by the continuity of $f_A$Now see that $f_A^{-1}(V)$ is closed in the subspace topology of $A$ means that
there is some closed $P \subseteq X$ such that $f|_A^{-1}(V) = A \cap P$.
Since both $A$ and $P$ are closed in $X$, this means that $f^{-1}(V)$ is closed
in $X$ (see that we have filted "closed in $A$" to "closed in $X$).
Similarly, we will have that $f|_B^{-1}(V) = B \cap Q$ for some closed $B$ and $Q$.
Then we can write:

$\begin{aligned}
&f^{-1}(V) \\
&= f|_A^{-1}(V) \cup f|_B^{-1}(B) \\
&= (A \cap P) \cup (B \cap Q) \\
&= \texttt{finite union of closed sets} \\
&= \texttt{closed} \\
\end{aligned}$