Characterisation of Continous function using 2 open sets 
Let $f:\mathbb  R\to \mathbb R$ be function .
  Define $2$ sets as A and B in $\mathbb R^2 $ as follows:
  A={$(x,y)|y<f(x)$},B={$(x,y)|y>f(x)$} .
  Then $f$ is continous on $\mathbb R$ iff A and B are open subset of $\mathbb R^2$
  

$\to $ to show A open that means for any $(a_1,a_2)\in A$ There exist some $r>0$ ball which contain in A .i.e $K=B_r((a_1,a_2))\subset A$
$(m,n)\in K$
As f is continous on R$\forall \epsilon >0,\exists \delta >0 $ such that $\forall x\in R$ $|x-y|<\delta$ then $|f(x)-f(y)|<\epsilon$ 
$f(a_1)>a_2$
I could not get idea to proceed further for any part.
Actually I don't able to understand how is this set look like.And How to use continuty assumption
Any help will be appreciated
 A: Take $(x_a,y_a) \in A$. By hypothesis, you have $y_a < f(x_a)$. As $f$ is supposed to be continuous on $\mathbb R$, it exists $\delta > 0$ such that $\vert f(x) - f(x_a) \vert < \dfrac{f(x_a) - y_a}{2}$ for $\vert x - x_a \vert < \delta$.
Therefore $\dfrac{y_a + f(x_a)}{2}< f(x)$ for $\vert x- x_a \vert < \delta$. Now take $r = \inf\left(\dfrac{f(x_a) - y_a}{2},\delta \right)$
Let's prove that the open ball $B((x_a,y_a),r)$ is included in $A$.
For that, take $(x,y) \in B((x_a,y_a),r)$. By hypothesis, we have 
$$\sqrt{(x-x_a)^2 + (y-y_a)^2} < r$$ which implies $\vert x - x_a \vert < \delta$ hence $\dfrac{y_a + f(x_a)}{2}< f(x)$ as we saw above. We also have $y-y_a < \dfrac{f(x_a) - y_a}{2}$. Therefore $y < \dfrac{y_a + f(x_a)}{2}< f(x)$, proving that $(x,y) \in A$ as desired.
This concludes the proof.
A: If $A$ is open in $\mathbb R^2$ then for every fixed $y\in\mathbb R$ the set $f^{-1}((y,\infty))=\{x\in\mathbb R\mid y<f(x)\}$ is open in $\mathbb R$.
If $B$ is open in $\mathbb R^2$ then for every fixed $y\in\mathbb R$ the set $f^{-1}((-\infty,y))=\{x\in\mathbb R\mid y>f(x)\}$ is open in $\mathbb R$.
The collection $\{(y,\infty)\mid y\in\mathbb R\}\cup\{(-\infty,y)\mid y\in\mathbb R\}$ is a subbasis for the (order) topology on $\mathbb R$ so from the fact that the preimages under $f$ are all open we are allowed to conclude that $f$ is continuous.

For the other side define the function $s:\mathbb R^2\to\mathbb R$ by $(x,y)\mapsto x-y$. This function is evidently continuous. Also the projections $\pi_1,\pi_2:\mathbb R^2\to\mathbb R$ are continuous.
Then the composition $f\circ\pi_2$ is continuous hence also the function $(\pi_1,f\circ\pi_2):\mathbb R^2\to\mathbb R^2$ is continuous. 
Now let $h:\mathbb R^2\to\mathbb R$ be the composition $s\circ(\pi_1,f\circ\pi_2)$. As composition of continuous functions $h$ itself is continuous.
So $h^{-1}(0,\infty)$ is open. 
Note that $h=s\circ(\pi_1,f\circ\pi_2)$ is actually prescribed by $(x,y)\mapsto x-f(y)$ so that $A=h^{-1}(0,\infty)$.
So proved is now that $A$ is open and similarly it can be proved that $B$ is open.
