You are using Lagrangian, it assumes interior solution.
Check your first order condition.
dL(p,m)/dx is independent of x and dL/dy isindependent of y. You cannot just make both of them to be 0.
The results are also ridiculous.
We know Dx=(m+p-1)/2 >= 0 and Dy=(m-p+1)/2p>=0
then m+p-1>=0 and m-p+1>=0
which means m>=1-p and m>=p-1. You will get p=1 and m=0, contradiction.
This problem only has corner solutions.
The demand functions are:
(x(p,m), y(p,m))= (m,0) if p>1
= (0,m/p) if p<1
= (m,0) or (0,m) if p=1
Many textbooks are wrong when using this example to teach the Lagrangian method.